mirror of
https://github.com/docker/setup-buildx-action.git
synced 2025-04-19 00:56:46 +00:00
Use built-in getExecOutput
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
faca7837b0
commit
29f1eeb9e5
6 changed files with 569 additions and 579 deletions
|
@ -1,18 +1,40 @@
|
|||
import fs = require('fs');
|
||||
import * as docker from '../src/docker';
|
||||
import * as buildx from '../src/buildx';
|
||||
import * as path from 'path';
|
||||
import * as os from 'os';
|
||||
import * as semver from 'semver';
|
||||
import * as exec from '@actions/exec';
|
||||
|
||||
describe('isAvailable', () => {
|
||||
const execSpy: jest.SpyInstance = jest.spyOn(exec, 'getExecOutput');
|
||||
buildx.isAvailable();
|
||||
|
||||
expect(execSpy).toHaveBeenCalledWith(`docker`, ['buildx'], {
|
||||
silent: true,
|
||||
ignoreReturnCode: true
|
||||
});
|
||||
});
|
||||
|
||||
describe('getVersion', () => {
|
||||
it('valid', async () => {
|
||||
await exec.exec('docker', ['buildx', 'version']);
|
||||
const version = await buildx.getVersion();
|
||||
console.log(`version: ${version}`);
|
||||
expect(semver.valid(version)).not.toBeNull();
|
||||
}, 100000);
|
||||
async function isDaemonRunning() {
|
||||
return await exec
|
||||
.getExecOutput(`docker`, ['version', '--format', '{{.Server.Os}}'], {
|
||||
ignoreReturnCode: true,
|
||||
silent: true
|
||||
})
|
||||
.then(res => {
|
||||
return !res.stdout.includes(' ') && res.exitCode == 0;
|
||||
});
|
||||
}
|
||||
(isDaemonRunning() ? it : it.skip)(
|
||||
'valid',
|
||||
async () => {
|
||||
const version = await buildx.getVersion();
|
||||
console.log(`version: ${version}`);
|
||||
expect(semver.valid(version)).not.toBeNull();
|
||||
},
|
||||
100000
|
||||
);
|
||||
});
|
||||
|
||||
describe('parseVersion', () => {
|
||||
|
@ -27,7 +49,14 @@ describe('parseVersion', () => {
|
|||
|
||||
describe('inspect', () => {
|
||||
async function isDaemonRunning() {
|
||||
return await docker.isDaemonRunning();
|
||||
return await exec
|
||||
.getExecOutput(`docker`, ['version', '--format', '{{.Server.Os}}'], {
|
||||
ignoreReturnCode: true,
|
||||
silent: true
|
||||
})
|
||||
.then(res => {
|
||||
return !res.stdout.includes(' ') && res.exitCode == 0;
|
||||
});
|
||||
}
|
||||
(isDaemonRunning() ? it : it.skip)(
|
||||
'valid',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue