From e9db81b6a1eeb6b6b6d625be92effb91609dfa08 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sun, 19 Feb 2023 02:47:49 +0100 Subject: [PATCH] docker: fix printVersion and printInfo Signed-off-by: CrazyMax --- __tests__/docker.test.ts | 34 ++++++---------------------------- src/docker.ts | 22 ++++------------------ 2 files changed, 10 insertions(+), 46 deletions(-) diff --git a/__tests__/docker.test.ts b/__tests__/docker.test.ts index 593df08..140b399 100644 --- a/__tests__/docker.test.ts +++ b/__tests__/docker.test.ts @@ -60,43 +60,21 @@ describe('isAvailable', () => { }); describe('printVersion', () => { - it('docker cli', async () => { + it('call docker version', async () => { const execSpy = jest.spyOn(exec, 'exec'); - await Docker.printVersion(false).catch(() => { + await Docker.printVersion().catch(() => { // noop }); - expect(execSpy).toHaveBeenCalledWith(`docker`, ['version'], { - failOnStdErr: false - }); - }); - it('standalone', async () => { - const execSpy = jest.spyOn(exec, 'exec'); - await Docker.printVersion(true).catch(() => { - // noop - }); - expect(execSpy).not.toHaveBeenCalledWith(`docker`, ['version'], { - failOnStdErr: false - }); + expect(execSpy).toHaveBeenCalledWith(`docker`, ['version']); }); }); describe('printInfo', () => { - it('docker cli', () => { + it('call docker info', async () => { const execSpy = jest.spyOn(exec, 'exec'); - Docker.printInfo(false).catch(() => { + await Docker.printInfo().catch(() => { // noop }); - expect(execSpy).toHaveBeenCalledWith(`docker`, ['info'], { - failOnStdErr: false - }); - }); - it('standalone', () => { - const execSpy = jest.spyOn(exec, 'exec'); - Docker.printInfo(true).catch(() => { - // noop - }); - expect(execSpy).not.toHaveBeenCalledWith(`docker`, ['info'], { - failOnStdErr: false - }); + expect(execSpy).toHaveBeenCalledWith(`docker`, ['info']); }); }); diff --git a/src/docker.ts b/src/docker.ts index 3f5a02a..5743fea 100644 --- a/src/docker.ts +++ b/src/docker.ts @@ -46,25 +46,11 @@ export class Docker { return ok; } - public static async printVersion(standalone?: boolean): Promise { - const noDocker = standalone ?? !(await Docker.isAvailable()); - if (noDocker) { - core.debug('Docker.printVersion: Docker is not available, skipping.'); - return; - } - await exec.exec('docker', ['version'], { - failOnStdErr: false - }); + public static async printVersion(): Promise { + await exec.exec('docker', ['version']); } - public static async printInfo(standalone?: boolean): Promise { - const noDocker = standalone ?? !(await Docker.isAvailable()); - if (noDocker) { - core.debug('Docker.printInfo: Docker is not available, skipping.'); - return; - } - await exec.exec('docker', ['info'], { - failOnStdErr: false - }); + public static async printInfo(): Promise { + await exec.exec('docker', ['info']); } }