// Stores which tests have been run, ensures single run per test tap.test('Profiling Data using Watchdog', function(t) { app.appmetrics.setConfig('advancedProfiling', { threshold: 1 }); app.appmetrics.enable('profiling'); monitor.on('profiling', function(data) { if (completedTests.watchdog != true) { t.type(app.appmetrics.watchdogActivationCount, 'function'); var activationCount = app.appmetrics.watchdogActivationCount(); t.ok(isInteger(activationCount) && activationCount > 0); runProfilingTests(data, t); t.end(); completedTests.watchdog = true; } }); });
test('parseHosts()', async (t) => { t.type(parseHosts, Function) const cases = [ ['0.0.0.0:4444', ['nats://0.0.0.0:4444'], 'simple string'] , [ ['localhost:4222', 'nats://localhost:1111'] , ['nats://localhost:4222', 'nats://localhost:1111'] , 'array options' ] ] for (const testcase of cases) { t.deepEqual(parseHosts(testcase[0]), testcase[1], testcase[2]) } t.throws(() => { parseHosts(null) }, /must be a string/ig) }).catch(threw)
tap.test('test reference verify sink double-pull sync', t => { t.plan(2) const source = new AssertionSource([ Buffer.alloc(10), Buffer.alloc(10), Buffer.alloc(10) ]) const sink = new DoublePullSink() const stream = new Stream(source, new Verify(), sink) t.throws(_ => { stream.start(error => { t.type(error, null) process.nextTick(_ => t.end()) }) }, { message: '[verify] pull was called after stream ended' }) })
test('.log() rejects invalid `opts` data type', (t) => { const logger = new Logger(apiKey, createOptions()) t.on('end', async () => { nock.cleanAll() }) nock(logger._url) .post('/', () => { return true }) .query(() => { return true }) .reply(200, 'Ingester response') logger.log('log line', 12345, (err, res) => { t.type(err, Error, 'Error was returned') t.equal( err.message , 'options parameter must be a level (string), or object' , 'Error message is correct' ) t.deepEqual(err.meta, {opts: 12345}, 'Meta is set on the error') t.end() }) })
await t.resolves(zabbix.login()) t.type(await new Zabbix({ url: 'http://127.0.0.1:8080/api_jsonrpc.php', user: 'Admin',
tt.type(files, Array, 'files is an array') tt.type(files, Array, 'files is an array') tt.type(files, Array, 'files is an array') tt.type(files, Array, 'files is an array') tt.equal(files.length, 3, 'File count is correct') tt.deepEqual(files.sort(), [ fileUtilities.getFiles({}, file, (err, files) => { tt.error(err, 'No error') tt.type(files, Array, 'files is an array') tt.equal(files.length, 1, 'File count is correct') tt.deepEqual(files, [file], 'Single filename is correct') tt.type(err, Error, 'Expected error received') tt.match(err, { name: 'Error' tt.type(err, Error, 'Expected error received') tt.match(err, { name: 'Error' tt.type(err, Error, 'Expected error received') tt.match(err, { name: 'Error'
tap.test('test reference verify sink double-pull', t => { t.plan(2) const source = new AssertionSource([ Buffer.alloc(10), Buffer.alloc(10), Buffer.alloc(10) ], Error) const sink = new DoublePullSink() const stream = new Stream(source, new Asyncify(), new Verify(), sink) stream.start(error => { t.type(error, Error) t.equal(error.message, '[verify] a pull() was already in progress, came from: [object Object]') t.end() }) })
test('parseHosts()', async (t) => { t.type(parseHosts, Function) const cases = [ ['0.0.0.0:4444', ['nats://0.0.0.0:4444'], 'simple string'] , [ ['localhost:4222', 'nats://localhost:1111'] , ['nats://localhost:4222', 'nats://localhost:1111'] , 'array options' ] ] for (const testcase of cases) { t.deepEqual(parseHosts(testcase[0]), testcase[1], testcase[2]) } t.throws(() => { parseHosts(null) }, /must be a string/ig) }).catch(threw)