buildx: printInspect

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2023-01-30 00:19:03 +01:00
parent c857b8425c
commit 4259682b27
No known key found for this signature in database
GPG Key ID: 3248E46B6BB8C7F7
3 changed files with 25 additions and 1 deletions

View File

@ -1,6 +1,7 @@
import {afterEach, beforeEach, describe, expect, it, jest, test} from '@jest/globals';
import {beforeEach, describe, expect, it, jest, test} from '@jest/globals';
import * as fs from 'fs';
import * as path from 'path';
import {Builder, BuilderInfo} from '../src/builder';
import {Context} from '../src/context';

View File

@ -151,6 +151,22 @@ describe('isAvailable', () => {
});
});
describe('printInspect', () => {
it('prints builder2 instance', () => {
const execSpy = jest.spyOn(exec, 'exec');
const buildx = new Buildx({
context: new Context(),
standalone: true
});
buildx.printInspect('builder2').catch(() => {
// noop
});
expect(execSpy).toHaveBeenCalledWith(`buildx`, ['inspect', 'builder2'], {
failOnStdErr: false
});
});
});
describe('printVersion', () => {
it('docker cli', () => {
const execSpy = jest.spyOn(exec, 'exec');

View File

@ -49,6 +49,13 @@ export class Buildx {
});
}
public async printInspect(name: string): Promise<void> {
const cmd = this.getCommand(['inspect', name]);
await exec.exec(cmd.command, cmd.args, {
failOnStdErr: false
});
}
private async getVersion(): Promise<string> {
const cmd = this.getCommand(['version']);
return await exec