Fix tests for gobin on Windows

This commit is contained in:
francisco souza 2020-03-01 21:34:51 -05:00
parent fecd8b0af8
commit 0dbc2e7f12
No known key found for this signature in database
GPG key ID: 3F6AA3B701F20B3E

View file

@ -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'));
}); });
}); });