it('passes an empty payload to the handler if none sent at dispatch', function(done) { const handler = sinon.spy(); const burns = require('../../src/burns'); burns.registerEvents({ eventZ: handler }); burns.dispatch('eventZ'); setTimeout(() => { expect(handler.calledOnce).to.equal(true); expect(handler.getCall(0).args[0]).to.deep.equal({}); done(); }, 0); });
it('should call pg_dump with some default args', async () => { const pgdumpProcess = mockSpawn()() const pgDumpFn = sinon.fake.returns(pgdumpProcess) const config = {} const p = pgdump(config, pgDumpFn) pgdumpProcess.stdout.write('PGDMP - data - data') pgdumpProcess.emit('close', 0) await p expect(pgDumpFn.calledOnce).to.be.true const pgDumpArgs = pgDumpFn.getCall(0).args[1] expect(pgDumpArgs).to.deep.equal(['-Fc', '-Z1']) })
it("must return function that calls '_resolve' under the hood and in case error calls callback with an error", () => { const error = new Error('some error'); const cbSpy = sinon.spy(); const resolveSpy = sinon .stub(lookup, '_resolve') .callsFake((hostname, options, cb) => { assert.strictEqual(resolveSpy.getCall(0).args[0], hostname); assert.strictEqual(resolveSpy.getCall(0).args[1], options); cb(error); }); const resolveTask = lookup._resolveTaskBuilder(hostname, options); resolveTask(cbSpy); assert.isTrue(resolveSpy.calledOnce); assert.strictEqual(resolveSpy.getCall(0).args[0], hostname); assert.strictEqual(resolveSpy.getCall(0).args[1], options); assert.instanceOf(resolveSpy.getCall(0).args[2], Function); assert.isTrue(cbSpy.calledOnce); assert.strictEqual(cbSpy.getCall(0).args.length, 1); assert.instanceOf(cbSpy.getCall(0).args[0], Error); assert.strictEqual(cbSpy.getCall(0).args[0].message, error.message); });
it("must return function that calls '_resolve' under the hood and in case no error calls callback with results", () => { const error = null; const results = [Symbol(), Symbol()]; const cbSpy = sinon.spy(); const resolveSpy = sinon .stub(lookup, '_resolve') .callsFake((hostname, options, cb) => { assert.strictEqual(resolveSpy.getCall(0).args[0], hostname); assert.strictEqual(resolveSpy.getCall(0).args[1], options); cb(error, ...results); }); const resolveTask = lookup._resolveTaskBuilder(hostname, options); resolveTask(cbSpy); assert.isTrue(resolveSpy.calledOnce); assert.strictEqual(resolveSpy.getCall(0).args[0], hostname); assert.strictEqual(resolveSpy.getCall(0).args[1], options); assert.instanceOf(resolveSpy.getCall(0).args[2], Function); assert.isTrue(cbSpy.calledOnce); assert.strictEqual(cbSpy.getCall(0).args.length, 3); assert.isNull(cbSpy.getCall(0).args[0]); assert.deepEqual(cbSpy.getCall(0).args.slice(1), results); });
expect(logSpy.getCall(0).args[0]).to.equal('GET /things - log a string') }) })
const onSignalSent = signalSocket.send.getCall(0).args[2]; t.ok(containsPassword(logger.info.getCall(0).args[0]), 'success message logged containing password'); t.ok(signalSocket.send.calledWith(['exit', JSON.stringify(expectedMessage)], 0, onSignalSent), 'exit signal containing password propagated to clients'); t.ok(batchSocket.close.called, 'batch socket closed');
expect(executionCookies.getCall(0).args).to.have.lengthOf(4); expect(executionCookies.getCall(0)).to.have.been .calledWith(1, 'store', 'findCookie'); methodArgs = executionCookies.getCall(0).args[3]; expect(executionCookies.getCall(1).args).to.have.lengthOf(4); expect(executionCookies.getCall(1)).to.have.been .calledWith(2, 'store', 'updateCookie'); methodArgs = executionCookies.getCall(1).args[3];
assert.strictEqual(addressCacheSetSpy.getCall(0).args[0], `${addresses.INET_HOST1}_${ipVersion}`); assert.instanceOf(addressCacheSetSpy.getCall(0).args[1], Array); assert.strictEqual(tasksManagerAddSpy.getCall(0).args[0], `${addresses.INET_HOST1}_${ipVersion}`); assert.instanceOf(tasksManagerAddSpy.getCall(0).args[1], ResolveTask);
it('should call pg_dump with provided extra arguments as array', async () => { const pgdumpProcess = mockSpawn()() const pgDumpFn = sinon.fake.returns(pgdumpProcess) const config = { PGDUMP_ARGS: ['--exclude-table=ignored-table', '-N', 'public'] } const p = pgdump(config, pgDumpFn) pgdumpProcess.stdout.write('PGDMP - data - data') pgdumpProcess.emit('close', 0) await p expect(pgDumpFn.calledOnce).to.be.true const pgDumpArgs = pgDumpFn.getCall(0).args[1] expect( pgDumpArgs ).to.deep.equal(['-Fc', '-Z1', '--exclude-table=ignored-table', '-N', 'public']) })
it('should call pg_dump with provided extra arguments as string', async () => { const pgdumpProcess = mockSpawn()() const pgDumpFn = sinon.fake.returns(pgdumpProcess) const config = { PGDUMP_ARGS: '--exclude-table=ignored-table -N public' } const p = pgdump(config, pgDumpFn) pgdumpProcess.stdout.write('PGDMP - data - data') pgdumpProcess.emit('close', 0) await p expect(pgDumpFn.calledOnce).to.be.true const pgDumpArgs = pgDumpFn.getCall(0).args[1] expect( pgDumpArgs ).to.deep.equal(['-Fc', '-Z1', '--exclude-table=ignored-table', '-N', 'public']) })