fake.returns({ restart: fake.resolves(true), exec: ({ Cmd }) => { const mockedStream = new stream.Readable(); return fake.resolves({ start: sinon.stub().yields(Cmd[0] === 'fail' ? 'error' : null, mockedStream), })(); }, })
it('rejects with an Error about ports on failure (with http)', async () => { createServersModule.yields(errs.create({ http: { errno: 'EADDRINUSE' } })); await start(); const expected = 'Port is already in use'; assume(gasketAPI.logger.error).calledWithMatch(expected); assume(debugStub.args[0][0].message).to.match(expected); assume(debugStub.args[0][1].http.errno).equals('EADDRINUSE'); });
it('should handle create error', () => { const error = new Error('error'); const sample = getSample(); const callback = sinon.stub(); sample.mocks.storagetransfer.transferJobs.create.yields(error); sample.program.createTransferJob({}, callback); assert.strictEqual(callback.calledOnce, true); assert.deepStrictEqual(callback.firstCall.args, [error]); });
it('rejects with an Error about ports on failure (with https)', async () => { createServersModule.yields(errs.create({ https: { errno: 'EADDRINUSE' } })); await start(); assume(debugStub.args[0][0].message).to.match('Port is already in use'); assume(debugStub.args[0][1].https.errno).equals('EADDRINUSE'); });
it('should handle auth error', () => { const error = new Error('error'); const sample = getSample(); const callback = sinon.stub(); sample.mocks.googleapis.google.auth.getApplicationDefault.yields(error); sample.program.createTransferJob({}, callback); assert.strictEqual(callback.calledOnce, true); assert.deepStrictEqual(callback.firstCall.args, [error]); });
it('rejects with an Error on failure', async () => { createServersModule.yields(errs.create({ https: { message: 'HTTP server failed to start', errno: 'something' } })); await start(); const expected = 'failed to start the http/https servers'; assume(gasketAPI.logger.error).calledWith(expected); assume(debugStub.args[0][0].message).equals(expected); assume(debugStub.args[0][1].https.message).equals('HTTP server failed to start'); });
it('should handle get error', () => { const error = new Error('error'); const sample = getSample(); const callback = sinon.stub(); sample.mocks.storagetransfer.transferOperations.get.yields(error); sample.program.getTransferOperation(jobName, callback); assert.strictEqual(callback.calledOnce, true); assert.deepStrictEqual(callback.firstCall.args, [error]); });
it('should handle auth error', () => { const error = new Error('error'); const sample = getSample(); const callback = sinon.stub(); sample.mocks.googleapis.google.auth.getApplicationDefault.yields(error); sample.program.listTransferJobs(callback); assert.strictEqual(callback.calledOnce, true); assert.deepStrictEqual(callback.firstCall.args, [error]); });
it('should handle resume error', () => { const error = new Error('error'); const sample = getSample(); const callback = sinon.stub(); sample.mocks.storagetransfer.transferOperations.resume.yields(error); sample.program.resumeTransferOperation(jobName, callback); assert.strictEqual(callback.calledOnce, true); assert.deepStrictEqual(callback.firstCall.args, [error]); });
it('should handle list error', () => { const error = new Error('error'); const sample = getSample(); const callback = sinon.stub(); sample.mocks.storagetransfer.transferJobs.list.yields(error); sample.program.listTransferJobs(callback); assert.strictEqual(callback.calledOnce, true); assert.deepStrictEqual(callback.firstCall.args, [error]); });
it('should handle auth error', () => { const error = new Error('error'); const sample = getSample(); const callback = sinon.stub(); sample.mocks.googleapis.google.auth.getApplicationDefault.yields(error); sample.program.resumeTransferOperation(jobName, callback); assert.strictEqual(callback.calledOnce, true); assert.deepStrictEqual(callback.firstCall.args, [error]); });
it('should handle get error', () => { const error = new Error('error'); const sample = getSample(); const callback = sinon.stub(); sample.mocks.storagetransfer.transferJobs.get.yields(error); sample.program.getTransferJob(jobName, callback); assert.strictEqual(callback.calledOnce, true); assert.deepStrictEqual(callback.firstCall.args, [error]); });
it('should handle auth error', () => { const error = new Error('error'); const sample = getSample(); const callback = sinon.stub(); sample.mocks.googleapis.google.auth.getApplicationDefault.yields(error); sample.program.pauseTransferOperation(jobName, callback); assert.strictEqual(callback.calledOnce, true); assert.deepStrictEqual(callback.firstCall.args, [error]); });
it('rejects with an Error about ports on failure (with https)', async () => { createServersModule.yields(errs.create({ https: { errno: 'EADDRINUSE' } })); await start(); assume(debugStub.args[0][0].message).to.match('Port is already in use'); assume(debugStub.args[0][1].https.errno).equals('EADDRINUSE'); });
it('rejects with an Error on failure', async () => { createServersModule.yields(errs.create({ https: { message: 'HTTP server failed to start', errno: 'something' } })); await start(); const expected = 'failed to start the http/https servers'; assume(gasketAPI.logger.error).calledWith(expected); assume(debugStub.args[0][0].message).equals(expected); assume(debugStub.args[0][1].https.message).equals('HTTP server failed to start'); });