test for await db.set in createAuthor

This commit is contained in:
webzwo0i 2021-04-18 00:50:35 +02:00 committed by Richard Hansen
parent a001a13411
commit 20c512c8a9

View file

@ -0,0 +1,31 @@
'use strict';
const AuthorManager = require('../../../node/db/AuthorManager');
const assert = require('assert').strict;
const common = require('../common');
const db = require('../../../node/db/DB');
describe(__filename, function () {
let setBackup;
before(async function () {
await common.init();
setBackup = db.set;
db.set = async (...args) => {
// delay db.set
await new Promise((resolve) => { setTimeout(() => resolve(), 500); });
return await setBackup.call(db, ...args);
};
});
after(async function () {
db.set = setBackup;
});
it('regression test for missing await in createAuthor (#5000)', async function () {
this.timeout(700);
const {authorID} = await AuthorManager.createAuthor(); // Should block until db.set() finishes.
assert(await AuthorManager.doesAuthorExist(authorID));
});
});