Convert version extraction to a function

Simplify how the version is extracted and add a simple test at the same
time.

Co-authored-by: Peter Mescalchin <peter@magnetikonline.com>
Co-authored-by: Brian Cristante <33549821+brcrista@users.noreply.github.com>
This commit is contained in:
Nicholas McDonnell 2022-04-08 02:25:56 -04:00
parent 2930331465
commit b2f8b6e6e0
No known key found for this signature in database
GPG key ID: 7994ADE2A56BE5D1
3 changed files with 24 additions and 13 deletions

View file

@ -105,6 +105,11 @@ describe('setup-go', () => {
jest.restoreAllMocks();
}, 100000);
it('can extract the major.minor.patch version from a given Go version string', async () => {
const goVersionOutput = 'go version go1.16.6 darwin/amd64';
expect(main.parseGoVersion(goVersionOutput)).toBe('1.16.6');
});
it('can find 1.9.7 from manifest on osx', async () => {
os.platform = 'darwin';
os.arch = 'x64';