2021-04-18 00:50:35 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const AuthorManager = require('../../../node/db/AuthorManager');
|
2024-02-22 18:31:17 +01:00
|
|
|
import {strict as assert} from "assert";
|
2021-04-18 00:50:35 +02:00
|
|
|
const common = require('../common');
|
|
|
|
const db = require('../../../node/db/DB');
|
|
|
|
|
|
|
|
describe(__filename, function () {
|
2024-02-22 18:31:17 +01:00
|
|
|
let setBackup: Function;
|
2021-04-18 00:50:35 +02:00
|
|
|
|
|
|
|
before(async function () {
|
|
|
|
await common.init();
|
|
|
|
setBackup = db.set;
|
|
|
|
|
2024-02-22 18:31:17 +01:00
|
|
|
db.set = async (...args:any) => {
|
2021-04-18 00:50:35 +02:00
|
|
|
// delay db.set
|
2024-02-22 18:31:17 +01:00
|
|
|
await new Promise<void>((resolve) => { setTimeout(() => resolve(), 500); });
|
2021-04-18 00:50:35 +02:00
|
|
|
return await setBackup.call(db, ...args);
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
after(async function () {
|
|
|
|
db.set = setBackup;
|
|
|
|
});
|
|
|
|
|
|
|
|
it('regression test for missing await in createAuthor (#5000)', async function () {
|
|
|
|
const {authorID} = await AuthorManager.createAuthor(); // Should block until db.set() finishes.
|
|
|
|
assert(await AuthorManager.doesAuthorExist(authorID));
|
|
|
|
});
|
|
|
|
});
|