mirror of
https://github.com/actions/setup-go.git
synced 2025-07-01 05:33:43 +00:00
Add tests
This commit is contained in:
parent
db0ba7321f
commit
b283174af6
2 changed files with 95 additions and 1 deletions
|
@ -957,4 +957,30 @@ use .
|
|||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('should not throw exception if `cache` is not set', async () => {
|
||||
process.env['GITHUB_WORKSPACE'] = '/tmp';
|
||||
|
||||
const arch = 'x64';
|
||||
os.platform = 'darwin';
|
||||
os.arch = arch;
|
||||
inputs['go-version'] = '1.17.6';
|
||||
inputs['architecture'] = os.arch;
|
||||
|
||||
const setFailedSpy = jest.spyOn(core, 'setFailed');
|
||||
setFailedSpy.mockImplementation(line => {
|
||||
process.stderr.write('log:' + line + '\n');
|
||||
});
|
||||
|
||||
existsSpy.mockImplementation(() => true);
|
||||
let toolPath = path.normalize('/cache/go/1.17.6/x64');
|
||||
findSpy.mockImplementation(() => false);
|
||||
dlSpy.mockImplementation(() => '/some/temp/path');
|
||||
extractTarSpy.mockImplementation(() => '/some/other/temp/path');
|
||||
cacheSpy.mockImplementation(() => toolPath);
|
||||
execSpy.mockImplementation(() => 'go version go1.17.6');
|
||||
|
||||
await main.run();
|
||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue