add support gowork for go-version-file

This commit is contained in:
koba1t
2022-11-01 19:13:57 +09:00
parent c4a742cab1
commit 7678c83214
7 changed files with 48 additions and 7 deletions

View File

@ -824,6 +824,12 @@ require (
replace example.com/thatmodule => ../thatmodule
exclude example.com/thismodule v1.3.0
`;
const goWorkContents = `go 1.19
use .
`;
it('reads version from go.mod', async () => {
@ -838,6 +844,18 @@ exclude example.com/thismodule v1.3.0
expect(logSpy).toHaveBeenCalledWith('matching 1.14...');
});
it('reads version from go.work', async () => {
inputs['go-version-file'] = 'go.work';
existsSpy.mockImplementation(() => true);
readFileSpy.mockImplementation(() => Buffer.from(goWorkContents));
await main.run();
expect(logSpy).toHaveBeenCalledWith('Setup go version spec 1.19');
expect(logSpy).toHaveBeenCalledWith('Attempting to download 1.19...');
expect(logSpy).toHaveBeenCalledWith('matching 1.19...');
});
it('reads version from .go-version', async () => {
inputs['go-version-file'] = '.go-version';
existsSpy.mockImplementation(() => true);