This commit is contained in:
Andras Schmelczer 2026-09-27 08:29:17 +01:00
commit 3dab48f58b

View file

@ -1,7 +1,7 @@
import assert from "node:assert/strict";
import { test } from "node:test";
import { fixture, bytes } from "./sync-fixture";
import { toStoredSnapshot } from "../sync-client/src/snapshot";
import { hashSnapshot } from "../sync-client/src/snapshot";
import { LocalChangesDuringReconciliation } from "../sync-client/src/errors/errors";
for (const equal of [false, true])
@ -78,7 +78,7 @@ test("content edited after planning is merged with the incoming snapshot", async
await f.files.apply(structuredClone(f.database.state), {
a: {
expected,
replacement: await toStoredSnapshot({
replacement: await hashSnapshot({
content: bytes("remote\nbase\n")
})
}
@ -95,7 +95,7 @@ test("deleting the source after planning does not resurrect it", async () => {
next.local.a = "remote.md";
await f.disk.userDelete("a.md");
await f.files.apply(next, {
a: { replacement: await toStoredSnapshot({ content: bytes("remote") }) }
a: { replacement: await hashSnapshot({ content: bytes("remote") }) }
});
assert.deepEqual(f.disk.userFiles(), new Map());
assert.deepEqual(f.database.state.local, {});
@ -111,7 +111,7 @@ for (const protect of ["ignore", "size"] as const)
else await f.settings.setSetting("maxFileSizeMB", 0);
await f.files.apply(next, {
a: {
replacement: await toStoredSnapshot({
replacement: await hashSnapshot({
content: bytes("remote")
})
}
@ -224,7 +224,7 @@ for (const phase of ["before", "durable"])
const original = structuredClone(f.database.state);
const write = {
expected: (await f.files.snapshot("a.md"))!,
replacement: await toStoredSnapshot({
replacement: await hashSnapshot({
content: bytes("remote\nbase\n")
})
};
@ -272,7 +272,7 @@ test("atomic updater includes an edit made after the last snapshot without unlin
await f.files.apply(structuredClone(f.database.state), {
a: {
expected,
replacement: await toStoredSnapshot({
replacement: await hashSnapshot({
content: bytes("remote\nbase\n")
})
}
@ -298,7 +298,7 @@ test("a failed atomic update leaves database metadata unchanged", async () => {
f.files.apply(structuredClone(original), {
a: {
expected: (await f.files.snapshot("a.md"))!,
replacement: await toStoredSnapshot({
replacement: await hashSnapshot({
content: bytes("remote")
})
}