Add tests that fail without this change and pass with it

This commit is contained in:
Leigh McCulloch 2020-12-04 09:34:42 -08:00
parent 7267bd9425
commit 82e49b01e9
No known key found for this signature in database
GPG key ID: 02EA740790312BC4
3 changed files with 61 additions and 0 deletions

View file

@ -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 '';