Preserve native Go environment names in action outputs (#793)
* preserve native Go environment names in action outputs * implement review comment * Add missing trailing newline to action.yml --------- Co-authored-by: mahabaleshwars <147705296+mahabaleshwars@users.noreply.github.com>
This commit is contained in:
co-authored by
mahabaleshwars
parent
e626ada899
commit
3bfff43db6
+16
-13
@@ -17,6 +17,7 @@ import goTestManifest from './data/versions-manifest.json' with {type: 'json'};
|
||||
|
||||
import type {IGoVersion} from '../src/installer.js';
|
||||
import type {IToolRelease} from '@actions/tool-cache';
|
||||
import {GO_ENV_OUTPUTS} from '../src/constants.js';
|
||||
|
||||
const httpClientGetJson = jest.fn();
|
||||
|
||||
@@ -697,17 +698,19 @@ describe('setup-go', () => {
|
||||
it('sets an output for each exposed variable', () => {
|
||||
main.setGoEnvOutputs(goEnv);
|
||||
|
||||
expect(setOutputSpy).toHaveBeenCalledWith('go-path', goEnv.GOPATH);
|
||||
expect(setOutputSpy).toHaveBeenCalledWith('go-bin', '');
|
||||
expect(setOutputSpy).toHaveBeenCalledWith('go-root', goEnv.GOROOT);
|
||||
expect(setOutputSpy).toHaveBeenCalledWith('go-cache', goEnv.GOCACHE);
|
||||
expect(setOutputSpy).toHaveBeenCalledWith(
|
||||
'go-mod-cache',
|
||||
goEnv.GOMODCACHE
|
||||
);
|
||||
expect(setOutputSpy).toHaveBeenCalledWith('go-os', goEnv.GOOS);
|
||||
expect(setOutputSpy).toHaveBeenCalledWith('go-arch', goEnv.GOARCH);
|
||||
expect(setOutputSpy).toHaveBeenCalledWith('go-tool-dir', goEnv.GOTOOLDIR);
|
||||
expect(GO_ENV_OUTPUTS).toEqual([
|
||||
'GOPATH',
|
||||
'GOBIN',
|
||||
'GOROOT',
|
||||
'GOCACHE',
|
||||
'GOMODCACHE',
|
||||
'GOOS',
|
||||
'GOARCH',
|
||||
'GOTOOLDIR'
|
||||
]);
|
||||
for (const name of GO_ENV_OUTPUTS) {
|
||||
expect(setOutputSpy).toHaveBeenCalledWith(name, goEnv[name] ?? '');
|
||||
}
|
||||
});
|
||||
|
||||
it('falls back to $GOPATH/bin when GOBIN is empty', () => {
|
||||
@@ -735,7 +738,7 @@ describe('setup-go', () => {
|
||||
|
||||
main.setGoEnvOutputs({...goEnv, GOPATH});
|
||||
|
||||
expect(setOutputSpy).toHaveBeenCalledWith('go-path', GOPATH);
|
||||
expect(setOutputSpy).toHaveBeenCalledWith('GOPATH', GOPATH);
|
||||
expect(setOutputSpy).toHaveBeenCalledWith(
|
||||
'go-bin-path',
|
||||
'/Users/testuser/go/bin'
|
||||
@@ -745,7 +748,7 @@ describe('setup-go', () => {
|
||||
it('leaves variables missing from go env -json empty', () => {
|
||||
main.setGoEnvOutputs({});
|
||||
|
||||
expect(setOutputSpy).toHaveBeenCalledWith('go-path', '');
|
||||
expect(setOutputSpy).toHaveBeenCalledWith('GOPATH', '');
|
||||
expect(setOutputSpy).toHaveBeenCalledWith('go-bin-path', '');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user