|
|
@ -8,7 +8,7 @@ describe('getCommandOutput', () => {
|
|
|
|
|
|
|
|
|
|
|
|
it('should return trimmed stdout in case of successful exit code', async () => {
|
|
|
|
it('should return trimmed stdout in case of successful exit code', async () => {
|
|
|
|
//Arrange
|
|
|
|
//Arrange
|
|
|
|
const stdoutResult = ' some stdout ';
|
|
|
|
const stdoutResult = ' stdout ';
|
|
|
|
const trimmedStdout = stdoutResult.trim();
|
|
|
|
const trimmedStdout = stdoutResult.trim();
|
|
|
|
|
|
|
|
|
|
|
|
getExecOutputSpy.mockImplementation((commandLine: string) => {
|
|
|
|
getExecOutputSpy.mockImplementation((commandLine: string) => {
|
|
|
@ -19,13 +19,13 @@ describe('getCommandOutput', () => {
|
|
|
|
|
|
|
|
|
|
|
|
//Act + Assert
|
|
|
|
//Act + Assert
|
|
|
|
return cacheUtils
|
|
|
|
return cacheUtils
|
|
|
|
.getCommandOutput('some command')
|
|
|
|
.getCommandOutput('command')
|
|
|
|
.then(data => expect(data).toBe(trimmedStdout));
|
|
|
|
.then(data => expect(data).toBe(trimmedStdout));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('should return error in case of unsuccessful exit code', async () => {
|
|
|
|
it('should return error in case of unsuccessful exit code', async () => {
|
|
|
|
//Arrange
|
|
|
|
//Arrange
|
|
|
|
const stderrResult = 'Some error message';
|
|
|
|
const stderrResult = 'error message';
|
|
|
|
|
|
|
|
|
|
|
|
getExecOutputSpy.mockImplementation((commandLine: string) => {
|
|
|
|
getExecOutputSpy.mockImplementation((commandLine: string) => {
|
|
|
|
return new Promise<exec.ExecOutput>(resolve => {
|
|
|
|
return new Promise<exec.ExecOutput>(resolve => {
|
|
|
@ -35,7 +35,7 @@ describe('getCommandOutput', () => {
|
|
|
|
|
|
|
|
|
|
|
|
//Act + Assert
|
|
|
|
//Act + Assert
|
|
|
|
expect(async () => {
|
|
|
|
expect(async () => {
|
|
|
|
await cacheUtils.getCommandOutput('some command');
|
|
|
|
await cacheUtils.getCommandOutput('command');
|
|
|
|
}).rejects.toThrow();
|
|
|
|
}).rejects.toThrow();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|