release: WRNexusJS 0.8.0
Quality / quality (ubuntu-latest) (push) Failing after 21s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
2026-08-02 23:18:51 +05:30
parent 87507edf59
commit 586a6db8ff
625 changed files with 243608 additions and 11210 deletions
+14
View File
@@ -10,6 +10,7 @@ import {
closeDatabases,
} from "../src/index.ts";
import { sqlite } from "../src/adapters/sqlite.ts";
import type { Db } from "../src/index.ts";
test("multi-database registry: default + named connections", async () => {
await closeDatabases(); // isolate from any prior state
@@ -78,3 +79,16 @@ test("closing the registry does not instantiate unused lazy databases", async ()
await closeDatabases();
expect(calls).toBe(0);
});
test("registry closes every database and clears itself when one close fails", async () => {
await closeDatabases();
let secondClosed = false;
const broken = { close: async () => Promise.reject(new Error("close failed")) } as Db;
const healthy = { close: () => void (secondClosed = true) } as Db;
setDb(broken);
registerDb("healthy", healthy);
await expect(closeDatabases()).rejects.toThrow("databases failed to close");
expect(secondClosed).toBe(true);
expect(databaseNames()).toEqual([]);
});