mirror of
https://github.com/actions/setup-go.git
synced 2025-04-23 17:40:50 +00:00
Fix tests for gobin on Windows
This commit is contained in:
parent
fecd8b0af8
commit
0dbc2e7f12
1 changed files with 4 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
||||||
import * as gobin from '../src/gobin';
|
import * as gobin from '../src/gobin';
|
||||||
|
import * as path from 'path';
|
||||||
|
|
||||||
jest.mock('child_process');
|
jest.mock('child_process');
|
||||||
|
|
||||||
|
@ -6,16 +7,17 @@ describe('gobin', () => {
|
||||||
const childProcess = require('child_process');
|
const childProcess = require('child_process');
|
||||||
|
|
||||||
let execSpy: jest.SpyInstance;
|
let execSpy: jest.SpyInstance;
|
||||||
|
let gopath = path.join('home', 'user', 'go');
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
execSpy = jest.spyOn(childProcess, 'exec');
|
execSpy = jest.spyOn(childProcess, 'exec');
|
||||||
execSpy.mockImplementation((_command, callback) => {
|
execSpy.mockImplementation((_command, callback) => {
|
||||||
callback('', {stdout: '/home/user/go', stderr: ''});
|
callback('', {stdout: gopath, stderr: ''});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return ${GOPATH}/bin', async () => {
|
it('should return ${GOPATH}/bin', async () => {
|
||||||
const gobinPath = await gobin.getGOBIN('...');
|
const gobinPath = await gobin.getGOBIN('...');
|
||||||
expect(gobinPath).toBe('/home/user/go/bin');
|
expect(gobinPath).toBe(path.join(gopath, 'bin'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue