|
|
|
|
@ -343,11 +343,11 @@ describe('setup-go', () => {
|
|
|
|
|
expect(fileName).toBe('go1.13.7.windows-386.zip');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('finds unstable pre-release version', async () => {
|
|
|
|
|
it('finds unstable release candidate', async () => {
|
|
|
|
|
os.platform = 'linux';
|
|
|
|
|
os.arch = 'x64';
|
|
|
|
|
|
|
|
|
|
// spec: 1.14, stable=false => go1.14rc1
|
|
|
|
|
// spec: 1.14.0-rc.1, stable=false => go1.14rc1
|
|
|
|
|
const match: IGoVersion | undefined = await im.findMatch('1.14.0-rc.1');
|
|
|
|
|
expect(match).toBeDefined();
|
|
|
|
|
const version: string = match ? match.version : '';
|
|
|
|
|
@ -356,6 +356,46 @@ describe('setup-go', () => {
|
|
|
|
|
expect(fileName).toBe('go1.14rc1.linux-amd64.tar.gz');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('finds unstable beta version', async () => {
|
|
|
|
|
os.platform = 'linux';
|
|
|
|
|
os.arch = 'x64';
|
|
|
|
|
|
|
|
|
|
// spec: 1.18.0-beta.2, stable=false => go1.18beta2
|
|
|
|
|
const match: im.IGoVersion | undefined =
|
|
|
|
|
await im.findMatch('1.18.0-beta.2');
|
|
|
|
|
expect(match).toBeDefined();
|
|
|
|
|
const version: string = match ? match.version : '';
|
|
|
|
|
expect(version).toBe('go1.18beta2');
|
|
|
|
|
const fileName = match ? match.files[0].filename : '';
|
|
|
|
|
expect(fileName).toBe('go1.18beta2.linux-amd64.tar.gz');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('finds unstable release candidate (go version format)', async () => {
|
|
|
|
|
os.platform = 'linux';
|
|
|
|
|
os.arch = 'x64';
|
|
|
|
|
|
|
|
|
|
// spec: 1.14rc1, stable=false => go1.14rc1
|
|
|
|
|
const match: im.IGoVersion | undefined = await im.findMatch('1.14rc1');
|
|
|
|
|
expect(match).toBeDefined();
|
|
|
|
|
const version: string = match ? match.version : '';
|
|
|
|
|
expect(version).toBe('go1.14rc1');
|
|
|
|
|
const fileName = match ? match.files[0].filename : '';
|
|
|
|
|
expect(fileName).toBe('go1.14rc1.linux-amd64.tar.gz');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('finds unstable beta version (go version format)', async () => {
|
|
|
|
|
os.platform = 'linux';
|
|
|
|
|
os.arch = 'x64';
|
|
|
|
|
|
|
|
|
|
// spec: 1.18beta2, stable=false => go1.18beta2
|
|
|
|
|
const match: im.IGoVersion | undefined = await im.findMatch('1.18beta2');
|
|
|
|
|
expect(match).toBeDefined();
|
|
|
|
|
const version: string = match ? match.version : '';
|
|
|
|
|
expect(version).toBe('go1.18beta2');
|
|
|
|
|
const fileName = match ? match.files[0].filename : '';
|
|
|
|
|
expect(fileName).toBe('go1.18beta2.linux-amd64.tar.gz');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('evaluates to stable with input as true', async () => {
|
|
|
|
|
inputs['go-version'] = '1.13.0';
|
|
|
|
|
inputs.stable = 'true';
|
|
|
|
|
@ -431,6 +471,26 @@ describe('setup-go', () => {
|
|
|
|
|
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('finds a rc version of go already in the cache', async () => {
|
|
|
|
|
inputs['go-version'] = '1.14rc1';
|
|
|
|
|
|
|
|
|
|
const toolPath = path.normalize('/cache/go/1.14.0rc.1/x64');
|
|
|
|
|
findSpy.mockImplementation(() => toolPath);
|
|
|
|
|
await main.run();
|
|
|
|
|
|
|
|
|
|
expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('finds a rc version in the cache and adds it to the path', async () => {
|
|
|
|
|
inputs['go-version'] = '1.14rc1';
|
|
|
|
|
const toolPath = path.normalize('/cache/go/1.14.0.rc.1/x64');
|
|
|
|
|
findSpy.mockImplementation(() => toolPath);
|
|
|
|
|
await main.run();
|
|
|
|
|
|
|
|
|
|
const expPath = path.join(toolPath, 'bin');
|
|
|
|
|
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('handles unhandled error and reports error', async () => {
|
|
|
|
|
const errMsg = 'unhandled error message';
|
|
|
|
|
inputs['go-version'] = '1.13.0';
|
|
|
|
|
@ -487,6 +547,51 @@ describe('setup-go', () => {
|
|
|
|
|
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('downloads a rc version not in the cache', async () => {
|
|
|
|
|
os.platform = 'linux';
|
|
|
|
|
os.arch = 'x64';
|
|
|
|
|
|
|
|
|
|
inputs['go-version'] = '1.14rc1';
|
|
|
|
|
|
|
|
|
|
findSpy.mockImplementation(() => '');
|
|
|
|
|
dlSpy.mockImplementation(() => '/some/temp/path');
|
|
|
|
|
const toolPath = path.normalize('/cache/go/1.14.0-rc.1/x64');
|
|
|
|
|
extractTarSpy.mockImplementation(() => '/some/other/temp/path');
|
|
|
|
|
cacheSpy.mockImplementation(() => toolPath);
|
|
|
|
|
await main.run();
|
|
|
|
|
|
|
|
|
|
const expPath = path.join(toolPath, 'bin');
|
|
|
|
|
|
|
|
|
|
expect(dlSpy).toHaveBeenCalled();
|
|
|
|
|
expect(extractTarSpy).toHaveBeenCalled();
|
|
|
|
|
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('downloads a rc version not in the cache (windows)', async () => {
|
|
|
|
|
os.platform = 'win32';
|
|
|
|
|
os.arch = 'x64';
|
|
|
|
|
|
|
|
|
|
inputs['go-version'] = '1.14rc1';
|
|
|
|
|
process.env['RUNNER_TEMP'] = 'C:\\temp\\';
|
|
|
|
|
|
|
|
|
|
findSpy.mockImplementation(() => '');
|
|
|
|
|
dlSpy.mockImplementation(() => 'C:\\temp\\some\\path');
|
|
|
|
|
extractZipSpy.mockImplementation(() => 'C:\\temp\\some\\other\\path');
|
|
|
|
|
|
|
|
|
|
const toolPath = path.normalize('C:\\cache\\go\\1.21.0-rc.2\\x64');
|
|
|
|
|
cacheSpy.mockImplementation(() => toolPath);
|
|
|
|
|
|
|
|
|
|
await main.run();
|
|
|
|
|
|
|
|
|
|
const expPath = path.win32.join(toolPath, 'bin');
|
|
|
|
|
expect(dlSpy).toHaveBeenCalledWith(
|
|
|
|
|
'https://go.dev/dl/go1.14rc1.windows-amd64.zip',
|
|
|
|
|
'C:\\temp\\go1.14rc1.windows-amd64.zip',
|
|
|
|
|
undefined
|
|
|
|
|
);
|
|
|
|
|
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('does not find a version that does not exist', async () => {
|
|
|
|
|
os.platform = 'linux';
|
|
|
|
|
os.arch = 'x64';
|
|
|
|
|
@ -1197,7 +1302,7 @@ use .
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('go-version-file-toolchain', () => {
|
|
|
|
|
const goVersions = ['1.22.0', '1.21rc2', '1.18'];
|
|
|
|
|
const goVersions = ['1.22.0', '1.21rc2', '1.18', '1.18beta2'];
|
|
|
|
|
const placeholderVersion = '1.19';
|
|
|
|
|
const buildGoMod = (
|
|
|
|
|
goVersion: string,
|
|
|
|
|
|