fix(db): share registry across bundled copies
This commit is contained in:
@@ -92,3 +92,16 @@ test("registry closes every database and clears itself when one close fails", as
|
||||
expect(secondClosed).toBe(true);
|
||||
expect(databaseNames()).toEqual([]);
|
||||
});
|
||||
|
||||
test("separately evaluated package copies share the process-wide registry", async () => {
|
||||
await closeDatabases();
|
||||
const secondCopy = await import(`../src/client.ts?copy=${crypto.randomUUID()}`);
|
||||
const main = createDb(sqlite(":memory:"));
|
||||
|
||||
setDb(main);
|
||||
expect(secondCopy.hasDb()).toBe(true);
|
||||
expect(secondCopy.getDb()).toBe(main);
|
||||
|
||||
await secondCopy.closeDatabases();
|
||||
expect(hasDb()).toBe(false);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user