From 2f7373a257325cce035d277f8c01088946a3b5ef Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Fri, 12 May 2023 13:58:30 +0200 Subject: [PATCH] Fix review points --- __tests__/__snapshots__/authutil.test.ts.snap | 22 +++++++-------- __tests__/authutil.test.ts | 28 +++++++++---------- __tests__/csc.test.ts | 2 +- __tests__/installer.test.ts | 13 ++++----- __tests__/setup-dotnet.test.ts | 12 ++++---- 5 files changed, 37 insertions(+), 40 deletions(-) diff --git a/__tests__/__snapshots__/authutil.test.ts.snap b/__tests__/__snapshots__/authutil.test.ts.snap index d310f14..0ea506b 100644 --- a/__tests__/__snapshots__/authutil.test.ts.snap +++ b/__tests__/__snapshots__/authutil.test.ts.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`authutil tests Existing config not in repo root, sets up a partial NuGet.config user/PAT for GPR 1`] = ` +exports[`authutil tests existing config not in repo root, sets up a partial NuGet.config user/PAT for GPR 1`] = ` " @@ -15,7 +15,7 @@ exports[`authutil tests Existing config not in repo root, sets up a partial NuGe " `; -exports[`authutil tests Existing config w/ Azure Artifacts source and NuGet.org, sets up a partial NuGet.config user/PAT for GPR 1`] = ` +exports[`authutil tests existing config w/ Azure Artifacts source and NuGet.org, sets up a partial NuGet.config user/PAT for GPR 1`] = ` " @@ -30,7 +30,7 @@ exports[`authutil tests Existing config w/ Azure Artifacts source and NuGet.org, " `; -exports[`authutil tests Existing config w/ GPR source and NuGet.org, sets up a partial NuGet.config user/PAT for GPR 1`] = ` +exports[`authutil tests existing config w/ GPR source and NuGet.org, sets up a partial NuGet.config user/PAT for GPR 1`] = ` " @@ -45,7 +45,7 @@ exports[`authutil tests Existing config w/ GPR source and NuGet.org, sets up a p " `; -exports[`authutil tests Existing config w/ no GPR sources, sets up a full NuGet.config with URL and user/PAT for GPR 1`] = ` +exports[`authutil tests existing config w/ no GPR sources, sets up a full NuGet.config with URL and user/PAT for GPR 1`] = ` " @@ -63,7 +63,7 @@ exports[`authutil tests Existing config w/ no GPR sources, sets up a full NuGet. " `; -exports[`authutil tests Existing config w/ no sources, sets up a full NuGet.config with URL and user/PAT for GPR 1`] = ` +exports[`authutil tests existing config w/ no sources, sets up a full NuGet.config with URL and user/PAT for GPR 1`] = ` " @@ -81,7 +81,7 @@ exports[`authutil tests Existing config w/ no sources, sets up a full NuGet.conf " `; -exports[`authutil tests Existing config w/ only Azure Artifacts source, sets up a partial NuGet.config user/PAT for GPR 1`] = ` +exports[`authutil tests existing config w/ only Azure Artifacts source, sets up a partial NuGet.config user/PAT for GPR 1`] = ` " @@ -96,7 +96,7 @@ exports[`authutil tests Existing config w/ only Azure Artifacts source, sets up " `; -exports[`authutil tests Existing config w/ only GPR source, sets up a partial NuGet.config user/PAT for GPR 1`] = ` +exports[`authutil tests existing config w/ only GPR source, sets up a partial NuGet.config user/PAT for GPR 1`] = ` " @@ -111,7 +111,7 @@ exports[`authutil tests Existing config w/ only GPR source, sets up a partial Nu " `; -exports[`authutil tests Existing config w/ two GPR sources, sets up a partial NuGet.config user/PAT for GPR 1`] = ` +exports[`authutil tests existing config w/ two GPR sources, sets up a partial NuGet.config user/PAT for GPR 1`] = ` " @@ -130,7 +130,7 @@ exports[`authutil tests Existing config w/ two GPR sources, sets up a partial Nu " `; -exports[`authutil tests No existing config, sets up a full NuGet.config with URL and other owner/PAT for GPR 1`] = ` +exports[`authutil tests no existing config, sets up a full NuGet.config with URL and other owner/PAT for GPR 1`] = ` " @@ -148,7 +148,7 @@ exports[`authutil tests No existing config, sets up a full NuGet.config with URL " `; -exports[`authutil tests No existing config, sets up a full NuGet.config with URL and token for other source 1`] = ` +exports[`authutil tests no existing config, sets up a full NuGet.config with URL and token for other source 1`] = ` " @@ -166,7 +166,7 @@ exports[`authutil tests No existing config, sets up a full NuGet.config with URL " `; -exports[`authutil tests No existing config, sets up a full NuGet.config with URL and user/PAT for GPR 1`] = ` +exports[`authutil tests no existing config, sets up a full NuGet.config with URL and user/PAT for GPR 1`] = ` " diff --git a/__tests__/authutil.test.ts b/__tests__/authutil.test.ts index 01dd435..3435cdf 100644 --- a/__tests__/authutil.test.ts +++ b/__tests__/authutil.test.ts @@ -91,7 +91,7 @@ describe('authutil tests', () => { process.env['NUGET_AUTH_TOKEN'] = ''; }); - it('No existing config, sets up a full NuGet.config with URL and user/PAT for GPR', async () => { + it('no existing config, sets up a full NuGet.config with URL and user/PAT for GPR', async () => { process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN'; auth.configAuthentication( 'https://nuget.pkg.github.com/OwnerName/index.json', @@ -104,7 +104,7 @@ describe('authutil tests', () => { ).toMatchSnapshot(); }); - it('No existing config, auth token environment variable not provided, throws', async () => { + it('no existing config, auth token environment variable not provided, throws', async () => { let thrown = false; try { auth.configAuthentication( @@ -118,7 +118,7 @@ describe('authutil tests', () => { expect(thrown).toBe(true); }); - it('No existing config, sets up a full NuGet.config with URL and other owner/PAT for GPR', async () => { + it('no existing config, sets up a full NuGet.config with URL and other owner/PAT for GPR', async () => { process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN'; process.env['INPUT_OWNER'] = 'otherorg'; auth.configAuthentication( @@ -132,7 +132,7 @@ describe('authutil tests', () => { ).toMatchSnapshot(); }); - it('Existing config (invalid), tries to parse an invalid NuGet.config and throws', async () => { + it('existing config (invalid), tries to parse an invalid NuGet.config and throws', async () => { process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN'; const inputNuGetConfigPath: string = path.join( fakeSourcesDirForTesting, @@ -152,7 +152,7 @@ describe('authutil tests', () => { expect(thrown).toBe(true); }); - it('Existing config w/ no sources, sets up a full NuGet.config with URL and user/PAT for GPR', async () => { + it('existing config w/ no sources, sets up a full NuGet.config with URL and user/PAT for GPR', async () => { process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN'; const inputNuGetConfigPath: string = path.join( fakeSourcesDirForTesting, @@ -170,7 +170,7 @@ describe('authutil tests', () => { ).toMatchSnapshot(); }); - it('Existing config w/ no GPR sources, sets up a full NuGet.config with URL and user/PAT for GPR', async () => { + it('existing config w/ no GPR sources, sets up a full NuGet.config with URL and user/PAT for GPR', async () => { process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN'; const inputNuGetConfigPath: string = path.join( fakeSourcesDirForTesting, @@ -188,7 +188,7 @@ describe('authutil tests', () => { ).toMatchSnapshot(); }); - it('Existing config w/ only GPR source, sets up a partial NuGet.config user/PAT for GPR', async () => { + it('existing config w/ only GPR source, sets up a partial NuGet.config user/PAT for GPR', async () => { process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN'; const inputNuGetConfigPath: string = path.join( fakeSourcesDirForTesting, @@ -206,7 +206,7 @@ describe('authutil tests', () => { ).toMatchSnapshot(); }); - it('Existing config w/ GPR source and NuGet.org, sets up a partial NuGet.config user/PAT for GPR', async () => { + it('existing config w/ GPR source and NuGet.org, sets up a partial NuGet.config user/PAT for GPR', async () => { process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN'; const inputNuGetConfigPath: string = path.join( fakeSourcesDirForTesting, @@ -224,7 +224,7 @@ describe('authutil tests', () => { ).toMatchSnapshot(); }); - it('Existing config w/ two GPR sources, sets up a partial NuGet.config user/PAT for GPR', async () => { + it('existing config w/ two GPR sources, sets up a partial NuGet.config user/PAT for GPR', async () => { process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN'; const inputNuGetConfigPath: string = path.join( fakeSourcesDirForTesting, @@ -242,7 +242,7 @@ describe('authutil tests', () => { ).toMatchSnapshot(); }); - it('Existing config w/ spaces in key, throws for now', async () => { + it('existing config w/ spaces in key, throws for now', async () => { process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN'; const inputNuGetConfigPath: string = path.join( fakeSourcesDirForTesting, @@ -262,7 +262,7 @@ describe('authutil tests', () => { expect(thrown).toBe(true); }); - it('Existing config not in repo root, sets up a partial NuGet.config user/PAT for GPR', async () => { + it('existing config not in repo root, sets up a partial NuGet.config user/PAT for GPR', async () => { process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN'; const inputNuGetConfigDirectory: string = path.join( fakeSourcesDirForTesting, @@ -285,7 +285,7 @@ describe('authutil tests', () => { ).toMatchSnapshot(); }); - it('Existing config w/ only Azure Artifacts source, sets up a partial NuGet.config user/PAT for GPR', async () => { + it('existing config w/ only Azure Artifacts source, sets up a partial NuGet.config user/PAT for GPR', async () => { process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN'; const inputNuGetConfigPath: string = path.join( fakeSourcesDirForTesting, @@ -303,7 +303,7 @@ describe('authutil tests', () => { ).toMatchSnapshot(); }); - it('Existing config w/ Azure Artifacts source and NuGet.org, sets up a partial NuGet.config user/PAT for GPR', async () => { + it('existing config w/ Azure Artifacts source and NuGet.org, sets up a partial NuGet.config user/PAT for GPR', async () => { process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN'; const inputNuGetConfigPath: string = path.join( fakeSourcesDirForTesting, @@ -321,7 +321,7 @@ describe('authutil tests', () => { ).toMatchSnapshot(); }); - it('No existing config, sets up a full NuGet.config with URL and token for other source', async () => { + it('no existing config, sets up a full NuGet.config with URL and token for other source', async () => { process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN'; auth.configAuthentication( 'https://pkgs.dev.azure.com/amullans/_packaging/GitHubBuilds/nuget/v3/index.json', diff --git a/__tests__/csc.test.ts b/__tests__/csc.test.ts index f4bfa92..8d43b39 100644 --- a/__tests__/csc.test.ts +++ b/__tests__/csc.test.ts @@ -1,6 +1,6 @@ import cscFile from '../.github/csc.json'; describe('csc tests', () => { - it('Valid regular expression', async () => { + test('regular expression in csc.json is valid', async () => { const regexPattern = cscFile['problemMatcher'][0]['pattern'][0]['regexp']; const regexResultsMap = cscFile['problemMatcher'][0]['pattern'][0]; diff --git a/__tests__/installer.test.ts b/__tests__/installer.test.ts index 302d972..b26d915 100644 --- a/__tests__/installer.test.ts +++ b/__tests__/installer.test.ts @@ -16,10 +16,6 @@ describe('installer tests', () => { process.env = {...env}; }); - afterEach(() => { - process.env = env; - }); - describe('DotnetCoreInstaller tests', () => { const getExecOutputSpy = jest.spyOn(exec, 'getExecOutput'); const warningSpy = jest.spyOn(core, 'warning'); @@ -32,7 +28,7 @@ describe('installer tests', () => { it('should throw the error in case of non-zero exit code of the installation script. The error message should contain logs.', async () => { const inputVersion = '3.1.100'; const inputQuality = '' as QualityOptions; - const errorMessage = 'Fictious error message!'; + const errorMessage = 'fictitious error message!'; getExecOutputSpy.mockImplementation(() => { return Promise.resolve({ exitCode: 1, @@ -252,16 +248,17 @@ describe('installer tests', () => { }); } }); + describe('addToPath() tests', () => { it(`should export DOTNET_ROOT env.var with value from DOTNET_INSTALL_DIR env.var`, async () => { - process.env['DOTNET_INSTALL_DIR'] = 'fictious/dotnet/install/dir'; + process.env['DOTNET_INSTALL_DIR'] = 'fictitious/dotnet/install/dir'; installer.DotnetCoreInstaller.addToPath(); const dotnet_root = process.env['DOTNET_ROOT']; expect(dotnet_root).toBe(process.env['DOTNET_INSTALL_DIR']); }); - it(`should export value from the DOTNET_INSTALL_DIR env.var to the PATH`, async () => { - process.env['DOTNET_INSTALL_DIR'] = 'fictious/dotnet/install/dir'; + it(`should export value from DOTNET_INSTALL_DIR env.var to the PATH`, async () => { + process.env['DOTNET_INSTALL_DIR'] = 'fictitious/dotnet/install/dir'; installer.DotnetCoreInstaller.addToPath(); const path = process.env['PATH']; expect(path).toContain(process.env['DOTNET_INSTALL_DIR']); diff --git a/__tests__/setup-dotnet.test.ts b/__tests__/setup-dotnet.test.ts index 78e10f4..831408c 100644 --- a/__tests__/setup-dotnet.test.ts +++ b/__tests__/setup-dotnet.test.ts @@ -40,7 +40,7 @@ describe('setup-dotnet tests', () => { }); it('should fail the action if global-json-file input is present, but the file does not exist in the file system', async () => { - inputs['global-json-file'] = 'fictious.json'; + inputs['global-json-file'] = 'fictitious.json'; inputs['dotnet-version'] = []; const expectedErrorMessage = `The specified global.json file '${inputs['global-json-file']}' does not exist`; @@ -49,7 +49,7 @@ describe('setup-dotnet tests', () => { expect(setFailedSpy).toHaveBeenCalledWith(expectedErrorMessage); }); - it('should log message into debug output, try to find global.json in the repo root, fail and log message into info output if the dotnet-version and global-json-file inputs are not present', async () => { + test(`if 'dotnet-version' and 'global-json-file' inputs aren't present, should log into debug output, try to find global.json in the repo root, fail and log message into info output`, async () => { inputs['global-json-file'] = ''; inputs['dotnet-version'] = []; @@ -70,7 +70,7 @@ describe('setup-dotnet tests', () => { it('should fail the action if quality is supplied but its value is not supported', async () => { inputs['global-json-file'] = ''; inputs['dotnet-version'] = ['6.0']; - inputs['dotnet-quality'] = 'fictiousQuality'; + inputs['dotnet-quality'] = 'fictitiousQuality'; const expectedErrorMessage = `${inputs['dotnet-quality']} is not a supported value for 'dotnet-quality' option. Supported values are: daily, signed, validated, preview, ga.`; @@ -105,7 +105,7 @@ describe('setup-dotnet tests', () => { inputs['global-json-file'] = ''; inputs['dotnet-version'] = []; inputs['dotnet-quality'] = ''; - inputs['source-url'] = 'fictious.source.url'; + inputs['source-url'] = 'fictitious.source.url'; configAuthenticationSpy.mockImplementation(() => {}); @@ -120,8 +120,8 @@ describe('setup-dotnet tests', () => { inputs['global-json-file'] = ''; inputs['dotnet-version'] = []; inputs['dotnet-quality'] = ''; - inputs['source-url'] = 'fictious.source.url'; - inputs['config-file'] = 'fictious.path'; + inputs['source-url'] = 'fictitious.source.url'; + inputs['config-file'] = 'fictitious.path'; configAuthenticationSpy.mockImplementation(() => {}); setOutputSpy.mockImplementation(() => {});