test: pin cleanLogLine at each of the four Journal sites of db.ts (#497)
A path glued to ";" keeps "jean" through withoutFolders alone: one test per site (failed close, failed checksum repair, stopped catch-up and its copy, failed preparation) turns red if that site goes back to the heuristic alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
c1d69d23c5
commit
66d687f1c2
1 changed files with 61 additions and 0 deletions
|
|
@ -933,6 +933,67 @@ describe("cleanLogLine: the known folders first, then withoutFolders (#497)", ()
|
|||
});
|
||||
});
|
||||
|
||||
describe("the four Journal sites of db.ts take both curtains (#497)", () => {
|
||||
// Glued to `;`, which starts no path: withoutFolders alone keeps `jean`.
|
||||
const GLUED = "x;/home/jean dupont/notes/x.db";
|
||||
|
||||
beforeEach(() => {
|
||||
setKnownFolders({ home: "/home/jean dupont" });
|
||||
vi.mocked(logWarn).mockClear();
|
||||
vi.mocked(logError).mockClear();
|
||||
});
|
||||
afterEach(() => {
|
||||
setKnownFolders({});
|
||||
});
|
||||
|
||||
it("a failed close of the previous connection", async () => {
|
||||
vi.mocked(h.fakeDb.close).mockImplementation(async () => {
|
||||
throw new Error(`close refused for ${GLUED}`);
|
||||
});
|
||||
h.fakeDb = makeFakeDb("next");
|
||||
|
||||
await connectToProfile("next.db");
|
||||
|
||||
expect(vi.mocked(logWarn).mock.calls.map((call) => call[0])).toEqual([
|
||||
"DB: closing the previous connection failed, continuing without it: close refused for x.db",
|
||||
]);
|
||||
});
|
||||
|
||||
it("a failed checksum repair", async () => {
|
||||
vi.mocked(invoke).mockImplementationOnce(async () => {
|
||||
throw `Cannot open database: unable to open database file: ${GLUED}`;
|
||||
});
|
||||
|
||||
await connectToProfile("profile_0a1b2c3d.db");
|
||||
|
||||
expect(vi.mocked(logError).mock.calls.map((call) => call[0])).toEqual([
|
||||
"Migration repair failed: Cannot open database: unable to open database file: x.db",
|
||||
]);
|
||||
});
|
||||
|
||||
it("a stopped catch-up, and the copy it names", () => {
|
||||
const lines = describePreparation(
|
||||
"x.db",
|
||||
report({ catch_up_error: `backup_failed: unable to open database: ${GLUED}`, catch_up_backup: GLUED })
|
||||
);
|
||||
expect(lines.errors).toEqual([
|
||||
"Profile x.db: database update stopped: backup_failed: unable to open database: x.db; copy of the previous state kept as x.db",
|
||||
]);
|
||||
});
|
||||
|
||||
it("a failed preparation", async () => {
|
||||
h.prepare = async () => {
|
||||
throw new Error(`Cannot read ${GLUED}`);
|
||||
};
|
||||
|
||||
await connectToProfile("profile_0a1b2c3d.db");
|
||||
|
||||
expect(vi.mocked(logError).mock.calls.map((call) => call[0])).toEqual([
|
||||
"Profile profile_0a1b2c3d.db: database preparation failed: Cannot read x.db",
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// connectToProfile waits for the known folders (#497). initKnownFolders()
|
||||
// runs once per module instance, so each test takes a fresh db.ts with its own
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue