Prevent modifying global array during sqlite testing
This commit is contained in:
parent
e91585f9ab
commit
01ab326e52
@ -111,7 +111,7 @@ describe("SQLite migrations", function () {
|
||||
it("has working down-migrations", async function () {
|
||||
await serialize_run("BEGIN EXCLUSIVE TRANSACTION");
|
||||
|
||||
for (const rollback of rollbacks.reverse()) {
|
||||
for (const rollback of rollbacks.slice().reverse()) {
|
||||
if (rollback.rollback_forbidden) {
|
||||
throw Error(
|
||||
"Try to write a down migration, if you really can't, flip this to a break"
|
||||
@ -132,7 +132,11 @@ describe("SQLite Message Storage", function () {
|
||||
this.timeout(util.isRunningOnCI() ? 25000 : 5000);
|
||||
this.slow(300);
|
||||
|
||||
const expectedPath = path.join(Config.getHomePath(), "logs", "testUser.sqlite3");
|
||||
const expectedPath = path.join(
|
||||
Config.getHomePath(),
|
||||
"logs",
|
||||
"testUser.sqlite3"
|
||||
);
|
||||
let store: MessageStorage;
|
||||
|
||||
function db_get_one(stmt: string, ...params: any[]): Promise<any> {
|
||||
@ -193,13 +197,19 @@ describe("SQLite Message Storage", function () {
|
||||
|
||||
it("should resolve an empty array when disabled", async function () {
|
||||
store.isEnabled = false;
|
||||
const messages = await store.getMessages(null as any, null as any, null as any);
|
||||
const messages = await store.getMessages(
|
||||
null as any,
|
||||
null as any,
|
||||
null as any
|
||||
);
|
||||
expect(messages).to.be.empty;
|
||||
store.isEnabled = true;
|
||||
});
|
||||
|
||||
it("should insert schema version to options table", async function () {
|
||||
const row = await db_get_one("SELECT value FROM options WHERE name = 'schema_version'");
|
||||
const row = await db_get_one(
|
||||
"SELECT value FROM options WHERE name = 'schema_version'"
|
||||
);
|
||||
expect(row.value).to.equal(currentSchemaVersion.toString());
|
||||
});
|
||||
|
||||
@ -268,7 +278,10 @@ describe("SQLite Message Storage", function () {
|
||||
() => msgId++
|
||||
);
|
||||
expect(messages).to.have.lengthOf(2);
|
||||
expect(messages.map((i_1) => i_1.text)).to.deep.equal(["msg 198", "msg 199"]);
|
||||
expect(messages.map((i_1) => i_1.text)).to.deep.equal([
|
||||
"msg 198",
|
||||
"msg 199",
|
||||
]);
|
||||
} finally {
|
||||
Config.values.maxHistory = originalMaxHistory;
|
||||
}
|
||||
@ -293,7 +306,9 @@ describe("SQLite Message Storage", function () {
|
||||
expectedMessages.push(`msg ${i}`);
|
||||
}
|
||||
|
||||
expect(search.results.map((i_1) => i_1.text)).to.deep.equal(expectedMessages);
|
||||
expect(search.results.map((i_1) => i_1.text)).to.deep.equal(
|
||||
expectedMessages
|
||||
);
|
||||
} finally {
|
||||
Config.values.maxHistory = originalMaxHistory;
|
||||
}
|
||||
@ -356,7 +371,7 @@ describe("SQLite Message Storage", function () {
|
||||
});
|
||||
|
||||
it("should be able to downgrade", async function () {
|
||||
for (const rollback of rollbacks.reverse()) {
|
||||
for (const rollback of rollbacks.slice().reverse()) {
|
||||
if (rollback.rollback_forbidden) {
|
||||
throw Error(
|
||||
"Try to write a down migration, if you really can't, flip this to a break"
|
||||
|
Loading…
Reference in New Issue
Block a user