mirror of
https://github.com/actions/setup-go.git
synced 2025-12-17 05:02:34 +00:00
feat: auto-detect go.mod when no version inputs specified
- Add unit tests for auto-detection behavior - Implement go.mod auto-detection in resolveVersionInput() - Explicit inputs still take precedence over auto-detection Related issue: #523
This commit is contained in:
parent
c0137caad7
commit
612cee1af9
3 changed files with 32 additions and 0 deletions
|
|
@ -1090,4 +1090,29 @@ use .
|
|||
expect(vars).toStrictEqual({GOTOOLCHAIN: 'local'});
|
||||
expect(process.env).toHaveProperty('GOTOOLCHAIN', 'local');
|
||||
});
|
||||
|
||||
describe('auto-detect go.mod', () => {
|
||||
it('uses go.mod from workspace root when no inputs provided', async () => {
|
||||
existsSpy.mockImplementation((filePath: string) => {
|
||||
return filePath === 'go.mod';
|
||||
});
|
||||
readFileSpy.mockImplementation(() =>
|
||||
Buffer.from('module test\n\ngo 1.20')
|
||||
);
|
||||
|
||||
await main.run();
|
||||
|
||||
expect(logSpy).toHaveBeenCalledWith('Setup go version spec 1.20');
|
||||
});
|
||||
|
||||
it('uses pre-installed Go when no inputs and no go.mod exists', async () => {
|
||||
existsSpy.mockImplementation(() => false);
|
||||
|
||||
await main.run();
|
||||
|
||||
expect(logSpy).toHaveBeenCalledWith(
|
||||
'[warning]go-version input was not specified. The action will try to use pre-installed version.'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue