docker: fix printVersion and printInfo
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
@@ -60,43 +60,21 @@ describe('isAvailable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('printVersion', () => {
|
describe('printVersion', () => {
|
||||||
it('docker cli', async () => {
|
it('call docker version', async () => {
|
||||||
const execSpy = jest.spyOn(exec, 'exec');
|
const execSpy = jest.spyOn(exec, 'exec');
|
||||||
await Docker.printVersion(false).catch(() => {
|
await Docker.printVersion().catch(() => {
|
||||||
// noop
|
// noop
|
||||||
});
|
});
|
||||||
expect(execSpy).toHaveBeenCalledWith(`docker`, ['version'], {
|
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
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('printInfo', () => {
|
describe('printInfo', () => {
|
||||||
it('docker cli', () => {
|
it('call docker info', async () => {
|
||||||
const execSpy = jest.spyOn(exec, 'exec');
|
const execSpy = jest.spyOn(exec, 'exec');
|
||||||
Docker.printInfo(false).catch(() => {
|
await Docker.printInfo().catch(() => {
|
||||||
// noop
|
// noop
|
||||||
});
|
});
|
||||||
expect(execSpy).toHaveBeenCalledWith(`docker`, ['info'], {
|
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
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -46,25 +46,11 @@ export class Docker {
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async printVersion(standalone?: boolean): Promise<void> {
|
public static async printVersion(): Promise<void> {
|
||||||
const noDocker = standalone ?? !(await Docker.isAvailable());
|
await exec.exec('docker', ['version']);
|
||||||
if (noDocker) {
|
|
||||||
core.debug('Docker.printVersion: Docker is not available, skipping.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await exec.exec('docker', ['version'], {
|
|
||||||
failOnStdErr: false
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async printInfo(standalone?: boolean): Promise<void> {
|
public static async printInfo(): Promise<void> {
|
||||||
const noDocker = standalone ?? !(await Docker.isAvailable());
|
await exec.exec('docker', ['info']);
|
||||||
if (noDocker) {
|
|
||||||
core.debug('Docker.printInfo: Docker is not available, skipping.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await exec.exec('docker', ['info'], {
|
|
||||||
failOnStdErr: false
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user