setup-go/__tests__/gobin.test.ts

24 lines
633 B
TypeScript
Raw Normal View History

import * as gobin from '../src/gobin';
2020-03-01 21:34:51 -05:00
import * as path from 'path';
jest.mock('child_process');
describe('gobin', () => {
const childProcess = require('child_process');
let execFileSpy: jest.SpyInstance;
2020-03-01 21:34:51 -05:00
let gopath = path.join('home', 'user', 'go');
beforeEach(() => {
execFileSpy = jest.spyOn(childProcess, 'execFile');
execFileSpy.mockImplementation((_file, _args, callback) => {
2020-03-01 21:34:51 -05:00
callback('', {stdout: gopath, stderr: ''});
});
});
it('should return ${GOPATH}/bin', async () => {
const gobinPath = await gobin.getGOBIN('...');
2020-03-01 21:34:51 -05:00
expect(gobinPath).toBe(path.join(gopath, 'bin'));
});
});