fix whitespace reformat and missing ;

This commit is contained in:
plukevdh 2023-05-19 15:32:26 -04:00
parent fc952ad45a
commit c401b8cb9d
No known key found for this signature in database
GPG key ID: 4CDF66F8A7057826
2 changed files with 64 additions and 65 deletions

View file

@ -138,7 +138,7 @@ describe('setup-go', () => {
expect(match!.resolvedVersion).toBe('1.9.7'); expect(match!.resolvedVersion).toBe('1.9.7');
expect(match!.type).toBe('manifest'); expect(match!.type).toBe('manifest');
expect(match!.downloadUrl).toBe( expect(match!.downloadUrl).toBe(
'https://github.com/actions/go-versions/releases/download/1.9.7/go-1.9.7-darwin-x64.tar.gz' 'https://github.com/actions/go-versions/releases/download/1.9.7/go-1.9.7-darwin-x64.tar.gz'
); );
}); });
@ -151,7 +151,7 @@ describe('setup-go', () => {
expect(match!.resolvedVersion).toBe('1.9.7'); expect(match!.resolvedVersion).toBe('1.9.7');
expect(match!.type).toBe('manifest'); expect(match!.type).toBe('manifest');
expect(match!.downloadUrl).toBe( expect(match!.downloadUrl).toBe(
'https://github.com/actions/go-versions/releases/download/1.9.7/go-1.9.7-linux-x64.tar.gz' 'https://github.com/actions/go-versions/releases/download/1.9.7/go-1.9.7-linux-x64.tar.gz'
); );
}); });
@ -164,7 +164,7 @@ describe('setup-go', () => {
expect(match!.resolvedVersion).toBe('1.9.7'); expect(match!.resolvedVersion).toBe('1.9.7');
expect(match!.type).toBe('manifest'); expect(match!.type).toBe('manifest');
expect(match!.downloadUrl).toBe( expect(match!.downloadUrl).toBe(
'https://github.com/actions/go-versions/releases/download/1.9.7/go-1.9.7-win32-x64.zip' 'https://github.com/actions/go-versions/releases/download/1.9.7/go-1.9.7-win32-x64.zip'
); );
}); });
@ -263,7 +263,7 @@ describe('setup-go', () => {
const toolPath = path.normalize('/cache/go/1.13.0/x64'); const toolPath = path.normalize('/cache/go/1.13.0/x64');
findSpy.mockImplementation(() => toolPath); findSpy.mockImplementation(() => toolPath);
const vars: { [key: string]: string } = {}; const vars: {[key: string]: string} = {};
exportVarSpy.mockImplementation((name: string, val: string) => { exportVarSpy.mockImplementation((name: string, val: string) => {
vars[name] = val; vars[name] = val;
}); });
@ -279,7 +279,7 @@ describe('setup-go', () => {
const toolPath = path.normalize('/cache/go/1.8.0/x64'); const toolPath = path.normalize('/cache/go/1.8.0/x64');
findSpy.mockImplementation(() => toolPath); findSpy.mockImplementation(() => toolPath);
const vars: { [key: string]: string } = {}; const vars: {[key: string]: string} = {};
exportVarSpy.mockImplementation((name: string, val: string) => { exportVarSpy.mockImplementation((name: string, val: string) => {
vars[name] = val; vars[name] = val;
}); });
@ -359,9 +359,9 @@ describe('setup-go', () => {
const expPath = path.win32.join(toolPath, 'bin'); const expPath = path.win32.join(toolPath, 'bin');
expect(dlSpy).toHaveBeenCalledWith( expect(dlSpy).toHaveBeenCalledWith(
'https://storage.googleapis.com/golang/go1.13.1.windows-amd64.zip', 'https://storage.googleapis.com/golang/go1.13.1.windows-amd64.zip',
'C:\\temp\\go1.13.1.windows-amd64.zip', 'C:\\temp\\go1.13.1.windows-amd64.zip',
undefined undefined
); );
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`); expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
}); });
@ -376,7 +376,7 @@ describe('setup-go', () => {
await main.run(); await main.run();
expect(cnSpy).toHaveBeenCalledWith( expect(cnSpy).toHaveBeenCalledWith(
`::error::Unable to find Go version '9.99.9' for platform linux and architecture x64.${osm.EOL}` `::error::Unable to find Go version '9.99.9' for platform linux and architecture x64.${osm.EOL}`
); );
}); });
@ -390,7 +390,7 @@ describe('setup-go', () => {
inputs['token'] = 'faketoken'; inputs['token'] = 'faketoken';
const expectedUrl = const expectedUrl =
'https://github.com/actions/go-versions/releases/download/1.12.16-20200616.20/go-1.12.16-linux-x64.tar.gz'; 'https://github.com/actions/go-versions/releases/download/1.12.16-20200616.20/go-1.12.16-linux-x64.tar.gz';
// ... but not in the local cache // ... but not in the local cache
findSpy.mockImplementation(() => ''); findSpy.mockImplementation(() => '');
@ -407,10 +407,10 @@ describe('setup-go', () => {
expect(dlSpy).toHaveBeenCalled(); expect(dlSpy).toHaveBeenCalled();
expect(extractTarSpy).toHaveBeenCalled(); expect(extractTarSpy).toHaveBeenCalled();
expect(logSpy).not.toHaveBeenCalledWith( expect(logSpy).not.toHaveBeenCalledWith(
'Not found in manifest. Falling back to download directly from Go' 'Not found in manifest. Falling back to download directly from Go'
); );
expect(logSpy).toHaveBeenCalledWith( expect(logSpy).toHaveBeenCalledWith(
`Acquiring 1.12.16 from ${expectedUrl}` `Acquiring 1.12.16 from ${expectedUrl}`
); );
expect(logSpy).toHaveBeenCalledWith(`Added go to the path`); expect(logSpy).toHaveBeenCalledWith(`Added go to the path`);
@ -427,7 +427,7 @@ describe('setup-go', () => {
inputs['token'] = 'faketoken'; inputs['token'] = 'faketoken';
const expectedUrl = const expectedUrl =
'https://github.com/actions/go-versions/releases/download/1.12.17-20200616.21/go-1.12.17-linux-x64.tar.gz'; 'https://github.com/actions/go-versions/releases/download/1.12.17-20200616.21/go-1.12.17-linux-x64.tar.gz';
// ... but not in the local cache // ... but not in the local cache
findSpy.mockImplementation(() => ''); findSpy.mockImplementation(() => '');
@ -444,10 +444,10 @@ describe('setup-go', () => {
expect(dlSpy).toHaveBeenCalled(); expect(dlSpy).toHaveBeenCalled();
expect(extractTarSpy).toHaveBeenCalled(); expect(extractTarSpy).toHaveBeenCalled();
expect(logSpy).not.toHaveBeenCalledWith( expect(logSpy).not.toHaveBeenCalledWith(
'Not found in manifest. Falling back to download directly from Go' 'Not found in manifest. Falling back to download directly from Go'
); );
expect(logSpy).toHaveBeenCalledWith( expect(logSpy).toHaveBeenCalledWith(
`Acquiring 1.12.17 from ${expectedUrl}` `Acquiring 1.12.17 from ${expectedUrl}`
); );
expect(logSpy).toHaveBeenCalledWith(`Added go to the path`); expect(logSpy).toHaveBeenCalledWith(`Added go to the path`);
@ -481,7 +481,7 @@ describe('setup-go', () => {
expect(logSpy).toHaveBeenCalledWith('matching 1.12.14...'); expect(logSpy).toHaveBeenCalledWith('matching 1.12.14...');
expect(extractTarSpy).toHaveBeenCalled(); expect(extractTarSpy).toHaveBeenCalled();
expect(logSpy).toHaveBeenCalledWith( expect(logSpy).toHaveBeenCalledWith(
'Not found in manifest. Falling back to download directly from Go' 'Not found in manifest. Falling back to download directly from Go'
); );
expect(logSpy).toHaveBeenCalledWith(`Install from dist`); expect(logSpy).toHaveBeenCalledWith(`Install from dist`);
expect(logSpy).toHaveBeenCalledWith(`Added go to the path`); expect(logSpy).toHaveBeenCalledWith(`Added go to the path`);
@ -502,7 +502,7 @@ describe('setup-go', () => {
await main.run(); await main.run();
expect(cnSpy).toHaveBeenCalledWith( expect(cnSpy).toHaveBeenCalledWith(
`::error::Failed to download version 1.13.1: Error: ${errMsg}${osm.EOL}` `::error::Failed to download version 1.13.1: Error: ${errMsg}${osm.EOL}`
); );
}); });
@ -523,8 +523,7 @@ describe('setup-go', () => {
return '/Users/testuser/go'; return '/Users/testuser/go';
}); });
mkdirpSpy.mockImplementation(async () => { mkdirpSpy.mockImplementation(async () => {});
});
existsSpy.mockImplementation(() => { existsSpy.mockImplementation(() => {
return false; return false;
}); });
@ -668,7 +667,7 @@ describe('setup-go', () => {
expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`); expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
expect(logSpy).not.toHaveBeenCalledWith( expect(logSpy).not.toHaveBeenCalledWith(
'Attempting to resolve the latest version from the manifest...' 'Attempting to resolve the latest version from the manifest...'
); );
}); });
@ -710,20 +709,20 @@ describe('setup-go', () => {
await main.run(); await main.run();
expect(logSpy).toHaveBeenCalledWith( expect(logSpy).toHaveBeenCalledWith(
`Setup go version spec ${versionSpec}` `Setup go version spec ${versionSpec}`
); );
expect(logSpy).toHaveBeenCalledWith( expect(logSpy).toHaveBeenCalledWith(
'Attempting to resolve the latest version from the manifest...' 'Attempting to resolve the latest version from the manifest...'
); );
expect(logSpy).toHaveBeenCalledWith(`Resolved as '${patchVersion}'`); expect(logSpy).toHaveBeenCalledWith(`Resolved as '${patchVersion}'`);
expect(logSpy).toHaveBeenCalledWith( expect(logSpy).toHaveBeenCalledWith(
`Attempting to download ${patchVersion}...` `Attempting to download ${patchVersion}...`
); );
expect(logSpy).toHaveBeenCalledWith('Extracting Go...'); expect(logSpy).toHaveBeenCalledWith('Extracting Go...');
expect(logSpy).toHaveBeenCalledWith('Adding to the cache ...'); expect(logSpy).toHaveBeenCalledWith('Adding to the cache ...');
expect(logSpy).toHaveBeenCalledWith('Added go to the path'); expect(logSpy).toHaveBeenCalledWith('Added go to the path');
expect(logSpy).toHaveBeenCalledWith( expect(logSpy).toHaveBeenCalledWith(
`Successfully set up Go version ${versionSpec}` `Successfully set up Go version ${versionSpec}`
); );
}); });
@ -753,13 +752,13 @@ describe('setup-go', () => {
expect(dlSpy).toHaveBeenCalled(); expect(dlSpy).toHaveBeenCalled();
expect(extractTarSpy).toHaveBeenCalled(); expect(extractTarSpy).toHaveBeenCalled();
expect(logSpy).toHaveBeenCalledWith( expect(logSpy).toHaveBeenCalledWith(
'Attempting to resolve the latest version from the manifest...' 'Attempting to resolve the latest version from the manifest...'
); );
expect(logSpy).toHaveBeenCalledWith( expect(logSpy).toHaveBeenCalledWith(
`Failed to resolve version ${versionSpec} from manifest` `Failed to resolve version ${versionSpec} from manifest`
); );
expect(logSpy).toHaveBeenCalledWith( expect(logSpy).toHaveBeenCalledWith(
`Attempting to download ${versionSpec}...` `Attempting to download ${versionSpec}...`
); );
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`); expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
}); });
@ -794,21 +793,21 @@ describe('setup-go', () => {
const expPath = path.join(toolPath, 'bin'); const expPath = path.join(toolPath, 'bin');
expect(logSpy).toHaveBeenCalledWith( expect(logSpy).toHaveBeenCalledWith(
`Failed to resolve version ${versionSpec} from manifest` `Failed to resolve version ${versionSpec} from manifest`
); );
expect(dlSpy).toHaveBeenCalled(); expect(dlSpy).toHaveBeenCalled();
expect(extractTarSpy).toHaveBeenCalled(); expect(extractTarSpy).toHaveBeenCalled();
expect(logSpy).toHaveBeenCalledWith( expect(logSpy).toHaveBeenCalledWith(
'Attempting to resolve the latest version from the manifest...' 'Attempting to resolve the latest version from the manifest...'
); );
expect(logSpy).toHaveBeenCalledWith( expect(logSpy).toHaveBeenCalledWith(
'Unable to resolve a version from the manifest...' 'Unable to resolve a version from the manifest...'
); );
expect(logSpy).toHaveBeenCalledWith( expect(logSpy).toHaveBeenCalledWith(
`Failed to resolve version ${versionSpec} from manifest` `Failed to resolve version ${versionSpec} from manifest`
); );
expect(logSpy).toHaveBeenCalledWith( expect(logSpy).toHaveBeenCalledWith(
`Attempting to download ${versionSpec}...` `Attempting to download ${versionSpec}...`
); );
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`); expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
@ -892,7 +891,7 @@ use .
await main.run(); await main.run();
expect(cnSpy).toHaveBeenCalledWith( expect(cnSpy).toHaveBeenCalledWith(
`::error::The specified go version file at: go.mod does not exist${osm.EOL}` `::error::The specified go version file at: go.mod does not exist${osm.EOL}`
); );
}); });
@ -912,9 +911,9 @@ use .
inputs['architecture'] = arch; inputs['architecture'] = arch;
const expectedUrl = const expectedUrl =
platform === 'win32' platform === 'win32'
? `https://github.com/actions/go-versions/releases/download/${version}/go-${version}-${platform}-${arch}.${fileExtension}` ? `https://github.com/actions/go-versions/releases/download/${version}/go-${version}-${platform}-${arch}.${fileExtension}`
: `https://storage.googleapis.com/golang/go${version}.${osSpec}-${arch}.${fileExtension}`; : `https://storage.googleapis.com/golang/go${version}.${osSpec}-${arch}.${fileExtension}`;
// ... but not in the local cache // ... but not in the local cache
findSpy.mockImplementation(() => ''); findSpy.mockImplementation(() => '');
@ -926,36 +925,36 @@ use .
await main.run(); await main.run();
expect(logSpy).toHaveBeenCalledWith( expect(logSpy).toHaveBeenCalledWith(
`Acquiring go${version} from ${expectedUrl}` `Acquiring go${version} from ${expectedUrl}`
); );
} }
}, 100000); }, 100000);
it.each(['stable', 'oldstable'])( it.each(['stable', 'oldstable'])(
'acquires latest go version with %s go-version input', 'acquires latest go version with %s go-version input',
async (alias: string) => { async (alias: string) => {
const arch = 'x64'; const arch = 'x64';
os.platform = 'darwin'; os.platform = 'darwin';
os.arch = arch; os.arch = arch;
inputs['go-version'] = alias; inputs['go-version'] = alias;
inputs['architecture'] = os.arch; inputs['architecture'] = os.arch;
// ... but not in the local cache // ... but not in the local cache
findSpy.mockImplementation(() => ''); findSpy.mockImplementation(() => '');
dlSpy.mockImplementation(async () => '/some/temp/path'); dlSpy.mockImplementation(async () => '/some/temp/path');
const toolPath = path.normalize(`/cache/go/${alias}/${arch}`); const toolPath = path.normalize(`/cache/go/${alias}/${arch}`);
cacheSpy.mockImplementation(async () => toolPath); cacheSpy.mockImplementation(async () => toolPath);
await main.run(); await main.run();
const releaseIndex = alias === 'stable' ? 0 : 1; const releaseIndex = alias === 'stable' ? 0 : 1;
expect(logSpy).toHaveBeenCalledWith( expect(logSpy).toHaveBeenCalledWith(
`${alias} version resolved as ${goTestManifest[releaseIndex].version}` `${alias} version resolved as ${goTestManifest[releaseIndex].version}`
); );
} }
); );
}); });
@ -967,9 +966,9 @@ ruby 3.2.1
`; `;
it('reads version from .tool-versions when specified', async () => { it('reads version from .tool-versions when specified', async () => {
inputs['tool-versions-file'] = '.special-tool-versions' inputs['tool-versions-file'] = '.special-tool-versions';
existsSpy.mockImplementation(() => true); existsSpy.mockImplementation(() => true);
readFileSpy.mockImplementation(() => Buffer.from(toolVersionsFile)) readFileSpy.mockImplementation(() => Buffer.from(toolVersionsFile));
await main.run(); await main.run();
@ -979,10 +978,10 @@ ruby 3.2.1
}); });
it('is overwritten by go-version param', async () => { it('is overwritten by go-version param', async () => {
inputs['go-version'] = '1.18.2' inputs['go-version'] = '1.18.2';
inputs['tool-versions-file'] = '.special-tool-versions' inputs['tool-versions-file'] = '.special-tool-versions';
existsSpy.mockImplementation(() => true); existsSpy.mockImplementation(() => true);
readFileSpy.mockImplementation(() => Buffer.from(toolVersionsFile)) readFileSpy.mockImplementation(() => Buffer.from(toolVersionsFile));
await main.run(); await main.run();
@ -993,7 +992,7 @@ ruby 3.2.1
it('uses .tool-versions as a default when no version specified', async () => { it('uses .tool-versions as a default when no version specified', async () => {
existsSpy.mockImplementation(() => true); existsSpy.mockImplementation(() => true);
readFileSpy.mockImplementation(() => Buffer.from(toolVersionsFile)) readFileSpy.mockImplementation(() => Buffer.from(toolVersionsFile));
await main.run(); await main.run();

View file

@ -160,19 +160,19 @@ function resolveVersionInput(): string {
if(toolVersionsPath && !fs.existsSync(toolVersionsPath)) { if(toolVersionsPath && !fs.existsSync(toolVersionsPath)) {
throw new Error( throw new Error(
`The specified .tool-versions file at ${toolVersionsPath} does not exist` `The specified .tool-versions file at ${toolVersionsPath} does not exist`
) );
} }
if (!toolVersionsPath) { if (!toolVersionsPath) {
toolVersionsPath = '.tool-versions' toolVersionsPath = '.tool-versions';
if(!fs.existsSync(toolVersionsPath)) { if(!fs.existsSync(toolVersionsPath)) {
throw new Error( throw new Error(
`No .tool-versions file was found in the project path. Please specify using tool-versions-file` `No .tool-versions file was found in the project path. Please specify using tool-versions-file`
) );
} }
} }
version = installer.parseToolVersionsFile(toolVersionsPath) version = installer.parseToolVersionsFile(toolVersionsPath);
} }
return version; return version;