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

View File

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

View File

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