mirror of
https://github.com/docker/setup-buildx-action.git
synced 2025-04-22 16:06:36 +02:00
Enhance builder inspection
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
abdb186058
commit
72750233ac
10 changed files with 215 additions and 53 deletions
|
@ -25,17 +25,19 @@ describe('parseVersion', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('platforms', () => {
|
||||
describe('inspect', () => {
|
||||
async function isDaemonRunning() {
|
||||
return await docker.isDaemonRunning();
|
||||
}
|
||||
(isDaemonRunning() ? it : it.skip)(
|
||||
'valid',
|
||||
async () => {
|
||||
const platforms = buildx.platforms();
|
||||
console.log(`platforms: ${platforms}`);
|
||||
expect(platforms).not.toBeUndefined();
|
||||
expect(platforms).not.toEqual('');
|
||||
const builder = await buildx.inspect('');
|
||||
console.log('builder', builder);
|
||||
expect(builder).not.toBeUndefined();
|
||||
expect(builder.name).not.toEqual('');
|
||||
expect(builder.driver).not.toEqual('');
|
||||
expect(builder.node_platforms).not.toEqual('');
|
||||
},
|
||||
100000
|
||||
);
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import * as os from 'os';
|
||||
import * as context from '../src/context';
|
||||
|
||||
describe('getInputList', () => {
|
||||
|
@ -78,6 +79,27 @@ describe('asyncForEach', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('setOutput', () => {
|
||||
beforeEach(() => {
|
||||
process.stdout.write = jest.fn();
|
||||
});
|
||||
|
||||
it('setOutput produces the correct command', () => {
|
||||
context.setOutput('some output', 'some value');
|
||||
assertWriteCalls([`::set-output name=some output::some value${os.EOL}`]);
|
||||
});
|
||||
|
||||
it('setOutput handles bools', () => {
|
||||
context.setOutput('some output', false);
|
||||
assertWriteCalls([`::set-output name=some output::false${os.EOL}`]);
|
||||
});
|
||||
|
||||
it('setOutput handles numbers', () => {
|
||||
context.setOutput('some output', 1.01);
|
||||
assertWriteCalls([`::set-output name=some output::1.01${os.EOL}`]);
|
||||
});
|
||||
});
|
||||
|
||||
// See: https://github.com/actions/toolkit/blob/master/packages/core/src/core.ts#L67
|
||||
function getInputName(name: string): string {
|
||||
return `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
|
||||
|
@ -86,3 +108,11 @@ function getInputName(name: string): string {
|
|||
function setInput(name: string, value: string): void {
|
||||
process.env[getInputName(name)] = value;
|
||||
}
|
||||
|
||||
// Assert that process.stdout.write calls called only with the given arguments.
|
||||
function assertWriteCalls(calls: string[]): void {
|
||||
expect(process.stdout.write).toHaveBeenCalledTimes(calls.length);
|
||||
for (let i = 0; i < calls.length; i++) {
|
||||
expect(process.stdout.write).toHaveBeenNthCalledWith(i + 1, calls[i]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue