....
This commit is contained in:
parent
3dab48f58b
commit
c869f0a880
6 changed files with 461 additions and 578 deletions
|
|
@ -183,13 +183,13 @@ test("conflict names respect component limits without imposing a total path limi
|
|||
const allocated = allocatePortablePath(
|
||||
wanted,
|
||||
"00000000-0000-4000-8000-000000000001",
|
||||
{ other: wanted }
|
||||
[wanted]
|
||||
);
|
||||
assert(Buffer.byteLength(allocated) <= 255);
|
||||
assert(allocated.endsWith(".md"));
|
||||
assert.notEqual(allocated, wanted);
|
||||
const longPath = "folder/".repeat(100) + "note.md";
|
||||
assert.equal(allocatePortablePath(longPath, "id", {}), longPath);
|
||||
assert.equal(allocatePortablePath(longPath, "id", []), longPath);
|
||||
});
|
||||
|
||||
test("an unmaterialized file with a directory at its path is deconflicted", async () => {
|
||||
|
|
|
|||
|
|
@ -68,11 +68,11 @@ for (const [count, delivery] of [
|
|||
}
|
||||
};
|
||||
const config = {
|
||||
initialize: async () => {
|
||||
getConfig: async () => {
|
||||
initializing.resolve();
|
||||
await initialized.promise;
|
||||
return { mergeableFileExtensions: ["md"] };
|
||||
},
|
||||
getConfig: async () => ({ mergeableFileExtensions: ["md"] }),
|
||||
reset: () => {}
|
||||
} as unknown as ServerConfig;
|
||||
const events: EventRecord[] = Array.from(
|
||||
|
|
|
|||
|
|
@ -111,7 +111,6 @@ async function fixture(syncIntervalMs: number | undefined) {
|
|||
async () => {}
|
||||
);
|
||||
const config = {
|
||||
initialize: async () => {},
|
||||
getConfig: async () => ({ mergeableFileExtensions: [] }),
|
||||
reset: () => {}
|
||||
} as unknown as ServerConfig;
|
||||
|
|
|
|||
|
|
@ -396,13 +396,12 @@ test("scan failures cannot masquerade as deletions", async () => {
|
|||
};
|
||||
await assert.rejects(
|
||||
scanLocalFiles({
|
||||
next: structuredClone(original),
|
||||
database: runtime.database,
|
||||
changes: [],
|
||||
files: runtime.files,
|
||||
guard: () => { },
|
||||
ignored: () => false,
|
||||
oversized: () => false,
|
||||
commit: (next) => runtime.database.commit(next)
|
||||
oversized: () => false
|
||||
}),
|
||||
/permission denied/
|
||||
);
|
||||
|
|
@ -424,13 +423,12 @@ for (const phase of ["before", "durable"]) {
|
|||
const scan = async () => {
|
||||
const runtime = current.restart();
|
||||
await scanLocalFiles({
|
||||
next: structuredClone(runtime.database.state),
|
||||
database: runtime.database,
|
||||
changes,
|
||||
files: runtime.files,
|
||||
guard: () => { },
|
||||
ignored: () => false,
|
||||
oversized: () => false,
|
||||
commit: (next) => runtime.database.commit(next)
|
||||
oversized: () => false
|
||||
});
|
||||
return runtime.database.state;
|
||||
};
|
||||
|
|
@ -458,13 +456,12 @@ async function scanChanges(
|
|||
): Promise<void> {
|
||||
await runtime.database.recoverPersistence();
|
||||
await scanLocalFiles({
|
||||
next: structuredClone(runtime.database.state),
|
||||
database: runtime.database,
|
||||
changes,
|
||||
files: runtime.files,
|
||||
guard: () => { },
|
||||
ignored: () => false,
|
||||
oversized: () => false,
|
||||
commit: (next) => runtime.database.commit(next)
|
||||
oversized: () => false
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -574,13 +571,12 @@ test("normalization-sensitive disk does not lose a distinct decomposed filename"
|
|||
await runtime.database.commit(next);
|
||||
await current.disk.userWrite("e\u0301.md", bytes("decomposed"));
|
||||
await scanLocalFiles({
|
||||
next: structuredClone(runtime.database.state),
|
||||
database: runtime.database,
|
||||
changes: [],
|
||||
files: runtime.files,
|
||||
guard: () => { },
|
||||
ignored: () => false,
|
||||
oversized: () => false,
|
||||
commit: (next) => runtime.database.commit(next)
|
||||
oversized: () => false
|
||||
});
|
||||
assert.equal(
|
||||
Object.keys(runtime.database.state.local).length,
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ test("a dirty cursor update must invalidate old precise positions", async () =>
|
|||
const tracker = new CursorTracker(
|
||||
f.database,
|
||||
ws as unknown as WebSocketManager,
|
||||
f.files,
|
||||
f.files.fs,
|
||||
new EventListeners()
|
||||
);
|
||||
let latest: import("../sync-client/src/types/maybe-outdated-client-cursors").MaybeOutdatedClientCursors[] =
|
||||
|
|
@ -436,7 +436,7 @@ test("conflict allocation terminates when a truncated extension ends in a space"
|
|||
`
|
||||
const {allocatePortablePath,validatePortablePaths} = require(${JSON.stringify(modulePath)});
|
||||
const name = 'a.' + 'x'.repeat(62) + ' ' + 'x'.repeat(100);
|
||||
const allocated = allocatePortablePath(name, 'new', {old:name});
|
||||
const allocated = allocatePortablePath(name, 'new', [name]);
|
||||
validatePortablePaths([name, allocated]);
|
||||
if (Buffer.byteLength(allocated) > 255) process.exit(2);
|
||||
`
|
||||
|
|
|
|||
|
|
@ -64,7 +64,6 @@ export async function fixture(
|
|||
async () => (await persistence.load()).database as StoredDatabase
|
||||
);
|
||||
const config = {
|
||||
initialize: async () => {},
|
||||
getConfig: async () => ({ mergeableFileExtensions: ["md"] }),
|
||||
reset: () => {}
|
||||
} as unknown as ServerConfig;
|
||||
|
|
|
|||
Loading…
Reference in a new issue