it('covers default', function () {
const result = common.attemptRetrySeconds(0);
assert(result >= 60);
- assert(result <= 60 * 1.618)
+ assert(result <= 60 * 1.618);
});
}); // attemptRetrySeconds
it('covers claim', async function () {
communication.db.topicFetchClaimById.resolves({
changes: 1,
- })
+ });
await communication.topicFetchClaimAndProcessById(dbCtx, topicId, requestId);
assert(communication.topicFetchProcess.called);
});
it('covers no claim', async function () {
communication.db.topicFetchClaimById.resolves({
changes: 0,
- })
+ });
await communication.topicFetchClaimAndProcessById(dbCtx, topicId, requestId);
assert(!communication.topicFetchProcess.called);
});
it('covers claim', async function () {
communication.db.verificationClaimById.resolves({
changes: 1,
- })
+ });
await communication.verificationClaimAndProcessById(dbCtx, verificationId, requestId);
assert(communication.verificationProcess.called);
});
it('covers no claim', async function () {
communication.db.verificationClaimById.resolves({
changes: 0,
- })
+ });
await communication.verificationClaimAndProcessById(dbCtx, verificationId, requestId);
assert(!communication.verificationProcess.called);
});
const data = {
...testData.subscriptionUpsert,
topicId,
- }
+ };
await db.context(async (dbCtx) => {
const result = await db.subscriptionUpsert(dbCtx, data);
assert(result.lastInsertRowid);
...testData.subscriptionUpsert,
secret: 'newSecret',
topicId,
- }
+ };
await db.context(async (dbCtx) => {
const result = await db.subscriptionUpsert(dbCtx, data);
assert(result.lastInsertRowid);
});
step('delete expired subscriptions', async function() {
await db.context(async (dbCtx) => {
- await db.subscriptionDeleteExpired(dbCtx, topicId)
+ await db.subscriptionDeleteExpired(dbCtx, topicId);
const subscription = await db.subscriptionGet(dbCtx, testData.subscriptionUpsert.callback, topicId);
assert(!subscription);
});
'use strict';
const assert = require('assert');
-const sinon = require('sinon');
+const sinon = require('sinon'); // eslint-disable-line node/no-unpublished-require
const stubLogger = require('../../stub-logger');
const Listener = require('../../../src/db/postgres/listener');
httpRemoteAddr = '127.0.0.1';
httpFrom = 'user@example.com';
wanted = 5;
-});
+ });
afterEach(function () {
sinon.restore();
});
const expected = new Error();
sinon.stub(db.db, 'manyOrNone').throws(expected);
try {
- await db.subscriptionDeliveryClaim(dbCtx, wanted, claimTimeoutSeconds, claimant );
+ await db.subscriptionDeliveryClaim(dbCtx, wanted, claimTimeoutSeconds, claimant);
assert.fail(noExpectedException);
} catch (e) {
assert.deepStrictEqual(e, expected);
changes: 1,
lastInsertRowid: 'c2e254c5-aa6e-4a8f-b1a1-e474b07392bb',
duration: 11,
- }
+ };
sinon.stub(db.db, 'result').resolves(dbResult);
const result = await db.subscriptionDeliveryClaimById(dbCtx, subscriptionId, claimTimeoutSeconds, claimant);
assert.deepStrictEqual(result, expected);
rowCount: 1,
rows: [],
duration: 10,
- }
+ };
const expected = {
changes: 1,
lastInsertRowid: undefined,
rowCount: 1,
rows: [],
duration: 10,
- }
+ };
const expected = {
changes: 1,
lastInsertRowid: undefined,
rowCount: 0,
rows: [],
duration: 10,
- }
+ };
sinon.stub(db.db, 'one').resolves(dbOne);
sinon.stub(db.db, 'result').onCall(0).resolves(dbResult0).onCall(1).resolves(dbResult1);
try {
rowCount: 0,
rows: [],
duration: 10,
- }
+ };
sinon.stub(db.db, 'one').resolves(dbOne);
sinon.stub(db.db, 'result').onCall(0).resolves(dbResult0).onCall(1).resolves(dbResult1);
try {
rowCount: 0,
rows: [],
duration: 10,
- }
+ };
sinon.stub(db.db, 'result').resolves(dbResult);
try {
await db.verificationUpdate(dbCtx, verificationId, data);
rowCount: 1,
rows: [],
duration: 10,
- }
+ };
sinon.stub(db.db, 'result').resolves(dbResult);
await db.verificationValidated(dbCtx, verificationId);
});
rowCount: 0,
rows: [],
duration: 10,
- }
+ };
sinon.stub(db.db, 'result').resolves(dbResult);
try {
await db.verificationValidated(dbCtx, verificationId);
.onCall(i++).returns(notDir) // 'init.sql'
.onCall(i++).returns(isDir).onCall(i++).returns(isMig) // '1.0.1'
.onCall(i++).returns(isDir).onCall(i++).returns(isMig) // '1.0.0'
+ ;
const result = svh.allSchemaVersions('path');
assert.deepStrictEqual(result, expected);
});
max: { major: 1, minor: 1, patch: 1 },
};
current = { major: 1, minor: 0, patch: 1 };
- });
+ });
it('covers', function () {
const expected = ['1.1.0', '1.1.1'];
fs.readdirSync.returns(['1.1.2', 'file.txt', '1.1.0', '1.1.1', 'init.sql', '1.0.1', '1.0.0']);
.onCall(i++).returns(notDir) // 'init.sql'
.onCall(i++).returns(isDir).onCall(i++).returns(isMig) // '1.0.1'
.onCall(i++).returns(isDir).onCall(i++).returns(isMig) // '1.0.0'
+ ;
const result = svh.unappliedSchemaVersions('path', current, supported);
assert.deepStrictEqual(result, expected);
});
contentFetchNextAttempt: now,
contentUpdated: now,
url: topic.url,
- }
+ };
const result = DB._topicDataToNative(topic);
assert.deepStrictEqual(result, expected);
});
const dbResult1 = {
changes: 1,
lastInsertRowid: undefined,
- }
+ };
const expected = {
changes: 1,
lastInsertRowid: undefined,
const dbResult1 = {
changes: 1,
lastInsertRowid: undefined,
- }
+ };
const expected = {
changes: 1,
lastInsertRowid: undefined,
const dbResult1 = {
changes: 0,
lastInsertRowid: undefined,
- }
+ };
sinon.stub(db.statement.topicAttempts, 'get').returns(dbGet);
sinon.stub(db.statement.topicAttemptsIncrement, 'run').returns(dbResult0);
sinon.stub(db.statement.topicContentFetchDone, 'run').returns(dbResult1);
const dbResult1 = {
changes: 0,
lastInsertRowid: undefined,
- }
+ };
sinon.stub(db.statement.topicAttempts, 'get').returns(dbGet);
sinon.stub(db.statement.topicAttemptsIncrement, 'run').returns(dbResult0);
sinon.stub(db.statement.topicContentFetchDone, 'run').returns(dbResult1);
DB._verificationDataToEngine(data);
assert.strictEqual(data.isPublisherValidated, 0);
});
- }) // _verificationDataToEngine
+ }); // _verificationDataToEngine
describe('verificationInsert', function () {
let verification;
const dbResult = {
changes: 0,
lastInsertRowid: undefined,
- }
+ };
sinon.stub(db.statement.verificationUpdate, 'run').returns(dbResult);
try {
await db.verificationUpdate(dbCtx, verificationId, data);
const dbResult = {
changes: 1,
lastInsertRowid: undefined,
- }
+ };
sinon.stub(db.statement.verificationValidate, 'run').returns(dbResult);
await db.verificationValidated(dbCtx, verificationId);
});
const dbResult = {
changes: 0,
lastInsertRowid: undefined,
- }
+ };
sinon.stub(db.statement.verificationValidate, 'run').returns(dbResult);
try {
await db.verificationValidated(dbCtx, verificationId);
describe('_getRootData', function () {
it('extracts expected values', function () {
req.getHeader.returns('user@example.com');
- ctx = Object.assign({}, testData.validSubscribeCtx)
+ ctx = Object.assign({}, testData.validSubscribeCtx);
const result = Manager._getRootData(req, ctx);
assert.deepStrictEqual(result, testData.validRootData);
});
assert(manager.db.topicFetchRequested.called);
assert.strictEqual(res.statusCode, 202);
assert(res.end.called);
- assert(manager.communication.topicFetchClaimAndProcessById.called)
+ assert(manager.communication.topicFetchClaimAndProcessById.called);
});
it('covers no immediate processing', async function() {
manager.options.manager.processImmediately = false;
assert(manager.db.topicFetchRequested.called);
assert.strictEqual(res.statusCode, 202);
assert(res.end.called);
- assert(!manager.communication.topicFetchClaimAndProcessById.called)
+ assert(!manager.communication.topicFetchClaimAndProcessById.called);
});
}); // _publishRequest
asyncLocalStorage = new AsyncLocalStorage();
options = new Config('test');
service = new Service(stubLogger, stubDb, options, asyncLocalStorage);
+ stubLogger._reset();
sinon.stub(service.manager);
sinon.stub(service.sessionManager);
sinon.stub(service.authenticator);
});
describe('preHandler', function () {
- it('logs requestId', async () => {
+ it('logs requestId', async function () {
sinon.stub(service.__proto__.__proto__, 'preHandler').resolves();
await service.asyncLocalStorage.run({}, async () => {
await service.preHandler(req, res, ctx);
assert('requestId' in logObject);
});
});
+ it('covers weird async context failure', async function () {
+ sinon.stub(service.__proto__.__proto__, 'preHandler').resolves();
+ sinon.stub(service.asyncLocalStorage, 'getStore').returns();
+ await service.preHandler(req, res, ctx);
+ assert(service.logger.debug.called);
+ });
}); // preHandler
describe('maybeIngestBody', function () {
await service.handlerGetAdminLogout(req, res, ctx);
assert(service.sessionManager.getAdminLogout.called);
});
-}); // handlerGetAdminLogout
+ }); // handlerGetAdminLogout
describe('handlerGetAdminIA', function () {
it('covers', async function () {
const assert = require('assert');
const template = require('../../../src/template/badge-svg');
-const Config = require('../../../config');
describe('Badge SVG Template', function () {
let ctx, label, message, accessibleText;