noop on cmd call test

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2023-01-24 01:21:26 +01:00
parent 66653922b3
commit b6f85576fa
No known key found for this signature in database
GPG Key ID: 3248E46B6BB8C7F7
3 changed files with 25 additions and 10 deletions

View File

@ -118,7 +118,9 @@ describe('isAvailable', () => {
const buildx = new Buildx({
standalone: false
});
await buildx.isAvailable();
buildx.isAvailable().catch(() => {
// noop
});
// eslint-disable-next-line jest/no-standalone-expect
expect(execSpy).toHaveBeenCalledWith(`docker`, ['buildx'], {
silent: true,
@ -130,7 +132,9 @@ describe('isAvailable', () => {
const buildx = new Buildx({
standalone: true
});
await buildx.isAvailable();
buildx.isAvailable().catch(() => {
// noop
});
// eslint-disable-next-line jest/no-standalone-expect
expect(execSpy).toHaveBeenCalledWith(`buildx`, [], {
silent: true,

View File

@ -11,7 +11,6 @@ describe('isAvailable', () => {
it('cli', () => {
const execSpy = jest.spyOn(exec, 'getExecOutput');
Docker.isAvailable();
// eslint-disable-next-line jest/no-standalone-expect
expect(execSpy).toHaveBeenCalledWith(`docker`, undefined, {
silent: true,
@ -23,14 +22,18 @@ describe('isAvailable', () => {
describe('printVersion', () => {
it('docker cli', () => {
const execSpy = jest.spyOn(exec, 'exec');
Docker.printVersion(false);
Docker.printVersion(false).catch(() => {
// noop
});
expect(execSpy).toHaveBeenCalledWith(`docker`, ['version'], {
failOnStdErr: false
});
});
it('standalone', () => {
const execSpy = jest.spyOn(exec, 'exec');
Docker.printVersion(true);
Docker.printVersion(true).catch(() => {
// noop
});
expect(execSpy).not.toHaveBeenCalledWith(`docker`, ['version'], {
failOnStdErr: false
});
@ -40,14 +43,18 @@ describe('printVersion', () => {
describe('printInfo', () => {
it('docker cli', () => {
const execSpy = jest.spyOn(exec, 'exec');
Docker.printInfo(false);
Docker.printInfo(false).catch(() => {
// noop
});
expect(execSpy).toHaveBeenCalledWith(`docker`, ['info'], {
failOnStdErr: false
});
});
it('standalone', () => {
const execSpy = jest.spyOn(exec, 'exec');
Docker.printInfo(true);
Docker.printInfo(true).catch(() => {
// noop
});
expect(execSpy).not.toHaveBeenCalledWith(`docker`, ['info'], {
failOnStdErr: false
});

View File

@ -7,7 +7,11 @@ beforeEach(() => {
describe('git', () => {
it('returns git remote ref', async () => {
const ref: string = await git.getRemoteSha('https://github.com/docker/buildx.git', 'refs/pull/648/head');
expect(ref).toEqual('f11797113e5a9b86bd976329c5dbb8a8bfdfadfa');
}, 100000);
try {
expect(await git.getRemoteSha('https://github.com/docker/buildx.git', 'refs/pull/648/head')).toEqual('f11797113e5a9b86bd976329c5dbb8a8bfdfadfa');
} catch (e) {
// eslint-disable-next-line jest/no-conditional-expect
expect(e).toEqual(null);
}
});
});