Use assert in test

This commit is contained in:
Haidang666
2021-08-01 14:59:25 +07:00
parent 3368615a77
commit 85e78d2490
2 changed files with 9 additions and 4 deletions

View File

@@ -1,10 +1,14 @@
import assert from "assert";
import {db, privateDB} from "../../src/databases/databases"; import {db, privateDB} from "../../src/databases/databases";
describe("dbUpgrade", () => { describe("dbUpgrade", () => {
it("Should update the database version when starting the application", async () => { it("Should update the database version when starting the application", async () => {
const dbVersion = (await db.prepare("get", "SELECT key, value FROM config where key = ?", ["version"])).value; const dbVersion = (await db.prepare("get", "SELECT key, value FROM config where key = ?", ["version"])).value;
const privateVersion = (await privateDB.prepare("get", "SELECT key, value FROM config where key = ?", ["version"])).value; const privateVersion = (await privateDB.prepare("get", "SELECT key, value FROM config where key = ?", ["version"])).value;
if (dbVersion >= 1 && privateVersion >= 1) return;
else return `Versions are not at least 1. db is ${dbVersion}, private is ${privateVersion}`; assert(
dbVersion >= 1 && privateVersion >= 1,
`Versions are not at least 1. db is ${dbVersion}, private is ${privateVersion}`);
}); });
}); });

View File

@@ -24,8 +24,9 @@ describe("getLockCategoriesByHash", () => {
it("Database should be greater or equal to version 20", async () => { it("Database should be greater or equal to version 20", async () => {
const version = (await db.prepare("get", "SELECT key, value FROM config where key = ?", ["version"])).value; const version = (await db.prepare("get", "SELECT key, value FROM config where key = ?", ["version"])).value;
if (version >= 20) return; assert(
else return `Version isn't greater than 20. Version is ${version}`; version >= 20,
`Version isn't greater than 20. Version is ${version}`);
}); });
it("Should be able to get multiple locks in one object", (done: Done) => { it("Should be able to get multiple locks in one object", (done: Done) => {