diff --git a/__tests__/setup-go.test.ts b/__tests__/setup-go.test.ts index c90d74b..01b1d73 100644 --- a/__tests__/setup-go.test.ts +++ b/__tests__/setup-go.test.ts @@ -427,6 +427,61 @@ describe('setup-go', () => { ); }); + it('adds GOBIN to PATH when go-version specified', async () => { + inputs['go-version'] = '1.13.0'; + + let toolPath = path.normalize('/cache/go/1.13.0/x64'); + findSpy.mockImplementation(() => toolPath); + + whichSpy.mockImplementation(async () => { + return '/usr/local/go/bin/go'; + }); + + execSpy.mockImplementation(() => { + return '/Users/testuser/go'; + }); + + mkdirpSpy.mockImplementation(async () => { }); + existsSpy.mockImplementation(path => { + return false; + }); + + await main.run(); + + expect(logSpy).toHaveBeenCalledWith(`Setup go stable version spec 1.13.0`); + expect(logSpy).toHaveBeenCalledWith(`Added go to the path`); + expect(logSpy).toHaveBeenCalledWith(`Added GOBIN to the path`); + + let expPath = "/Users/testuser/go/bin"; + expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`); + }); + + it('adds GOBIN to PATH when go-version not specified', async () => { + let toolPath = path.normalize('/cache/go/1.13.0/x64'); + findSpy.mockImplementation(() => toolPath); + + whichSpy.mockImplementation(async () => { + return '/usr/local/go/bin/go'; + }); + + execSpy.mockImplementation(() => { + return '/Users/testuser/go'; + }); + + mkdirpSpy.mockImplementation(async () => { }); + existsSpy.mockImplementation(path => { + return false; + }); + + await main.run(); + + expect(logSpy).toHaveBeenCalledWith(`Setup go stable version spec undefined`); + expect(logSpy).toHaveBeenCalledWith(`Added GOBIN to the path`); + + let expPath = "/Users/testuser/go/bin"; + expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`); + }); + it('does not add BIN if go is not in path', async () => { whichSpy.mockImplementation(async () => { return ''; diff --git a/dist/index.js b/dist/index.js index 0c05f5e..931527d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1511,6 +1511,9 @@ function run() { // add gobin to path let added = yield addBinToPath(); core.debug(`add bin ${added}`); + if (added) { + core.info('Added GOBIN to the path'); + } // add problem matchers const matchersPath = path_1.default.join(__dirname, '..', 'matchers.json'); core.info(`##[add-matcher]${matchersPath}`); diff --git a/src/main.ts b/src/main.ts index 027566b..cd8b953 100644 --- a/src/main.ts +++ b/src/main.ts @@ -36,6 +36,9 @@ export async function run() { // add gobin to path let added = await addBinToPath(); core.debug(`add bin ${added}`); + if (added) { + core.info('Added GOBIN to the path'); + } // add problem matchers const matchersPath = path.join(__dirname, '..', 'matchers.json');