mirror of
https://github.com/docker/actions-toolkit.git
synced 2024-11-26 22:26:08 +08:00
buildx: printVersion
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
4f2a155c08
commit
fe75972f55
@ -135,6 +135,29 @@ describe('isAvailable', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('printVersion', () => {
|
||||||
|
it('docker cli', () => {
|
||||||
|
const execSpy = jest.spyOn(exec, 'exec');
|
||||||
|
const buildx = new Buildx({
|
||||||
|
standalone: false
|
||||||
|
});
|
||||||
|
buildx.printVersion();
|
||||||
|
expect(execSpy).toHaveBeenCalledWith(`docker`, ['buildx', 'version'], {
|
||||||
|
failOnStdErr: false
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it('standalone', () => {
|
||||||
|
const execSpy = jest.spyOn(exec, 'exec');
|
||||||
|
const buildx = new Buildx({
|
||||||
|
standalone: true
|
||||||
|
});
|
||||||
|
buildx.printVersion();
|
||||||
|
expect(execSpy).toHaveBeenCalledWith(`buildx`, ['version'], {
|
||||||
|
failOnStdErr: false
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('getVersion', () => {
|
describe('getVersion', () => {
|
||||||
it('valid', async () => {
|
it('valid', async () => {
|
||||||
const buildx = new Buildx();
|
const buildx = new Buildx();
|
||||||
|
@ -17,7 +17,7 @@ describe('isAvailable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('printVersion', () => {
|
describe('printVersion', () => {
|
||||||
it('standard', () => {
|
it('docker cli', () => {
|
||||||
const execSpy = jest.spyOn(exec, 'exec');
|
const execSpy = jest.spyOn(exec, 'exec');
|
||||||
Docker.printVersion(false);
|
Docker.printVersion(false);
|
||||||
expect(execSpy).toHaveBeenCalledWith(`docker`, ['version'], {
|
expect(execSpy).toHaveBeenCalledWith(`docker`, ['version'], {
|
||||||
@ -34,7 +34,7 @@ describe('printVersion', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('printInfo', () => {
|
describe('printInfo', () => {
|
||||||
it('standard', () => {
|
it('docker cli', () => {
|
||||||
const execSpy = jest.spyOn(exec, 'exec');
|
const execSpy = jest.spyOn(exec, 'exec');
|
||||||
Docker.printInfo(false);
|
Docker.printInfo(false);
|
||||||
expect(execSpy).toHaveBeenCalledWith(`docker`, ['info'], {
|
expect(execSpy).toHaveBeenCalledWith(`docker`, ['info'], {
|
||||||
|
@ -71,6 +71,13 @@ export class Buildx {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async printVersion() {
|
||||||
|
const cmd = this.getCommand(['version']);
|
||||||
|
await exec.exec(cmd.command, cmd.args, {
|
||||||
|
failOnStdErr: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public static parseVersion(stdout: string): string {
|
public static parseVersion(stdout: string): string {
|
||||||
const matches = /\sv?([0-9a-f]{7}|[0-9.]+)/.exec(stdout);
|
const matches = /\sv?([0-9a-f]{7}|[0-9.]+)/.exec(stdout);
|
||||||
if (!matches) {
|
if (!matches) {
|
||||||
|
Loading…
Reference in New Issue
Block a user