mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-11-15 12:40:12 +00:00
Merge CLI database continuity into shared runtime integration
This commit is contained in:
commit
61b51bcb4e
21 files changed
+1587
-62
No files matched your search
@@ -1,6 +1,8 @@
|
||||
import { describe, expect, it, vi, beforeEach } from "vitest";
|
||||
import type { IStorageEventWatchHandlers } from "@vrtmrz/livesync-commonlib/compat/managers/adapters";
|
||||
import type { NodeFile } from "@/apps/cli/adapters/NodeTypes";
|
||||
import { fs, os, path } from "@vrtmrz/livesync-commonlib/node";
|
||||
import { runtimeScopeDirectory } from "../runtimeState";
|
||||
|
||||
// ── chokidar mock ──────────────────────────────────────────────────────────────
|
||||
// Must be hoisted before imports that pull in chokidar.
|
||||
@@ -44,6 +46,27 @@ describe("CLIStorageEventManagerAdapter", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps pending snapshots with the selected database and Vault pair", async () => {
|
||||
const directory = fs.mkdtempSync(path.join(os.tmpdir(), "livesync-snapshot-"));
|
||||
let database = "first";
|
||||
let vault = "vault-a";
|
||||
const adapter = new CLIStorageEventManagerAdapter(directory, undefined, false, undefined, () =>
|
||||
path.join(runtimeScopeDirectory(directory, database, vault), "storage-events.json")
|
||||
);
|
||||
try {
|
||||
await adapter.persistence.saveSnapshot([{ type: "SENTINEL_FLUSH" }]);
|
||||
database = "second";
|
||||
expect(await adapter.persistence.loadSnapshot()).toBeNull();
|
||||
database = "first";
|
||||
vault = "vault-b";
|
||||
expect(await adapter.persistence.loadSnapshot()).toBeNull();
|
||||
vault = "vault-a";
|
||||
expect(await adapter.persistence.loadSnapshot()).toEqual([{ type: "SENTINEL_FLUSH" }]);
|
||||
} finally {
|
||||
fs.rmSync(directory, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
it("beginWatch is no-op when watchEnabled=false", async () => {
|
||||
const adapter = new CLIStorageEventManagerAdapter("/base", undefined, false);
|
||||
const handlers = makeHandlers();
|
||||
|
||||
Reference in new issue
Block a user