Updates
Rolling release / release (push) Failing after 1m44s

This commit is contained in:
2026-09-14 12:15:47 -04:00
parent af9246151f
commit 08554c205c
8 changed files with 169 additions and 44 deletions
+32 -2
View File
@@ -74,11 +74,41 @@ test('memory opt-out covers direct paths, listing, search, and trash; disabling
vault.configure({ obsidianEnabled: false, obsidianVaultPath: root });
assert.throws(() => tool.execute({ action: 'list' }), /disabled/);
});
test('oversized reads and writes, colliding moves and restore are rejected', t => {
test('large files are readable, oversized writes and colliding moves/restore are rejected', t => {
const { vault, root } = fixture(t); vault.initialize();
assert.throws(() => vault.write('big.md', 'a'.repeat(2 * 1024 * 1024 + 1)), /limit/);
fs.writeFileSync(path.join(root, 'big.md'), Buffer.alloc(2 * 1024 * 1024 + 1)); assert.throws(() => vault.read('big.md'), /limit/);
fs.writeFileSync(path.join(root, 'big.md'), Buffer.alloc(2 * 1024 * 1024 + 1)); assert.equal(vault.read('big.md').complete, false);
assert.equal(vault.read('big.md', 'base64', { offset: 2 * 1024 * 1024 }).complete, true);
const note = vault.write('a.md', 'a'); vault.write('b.md', 'b');
assert.throws(() => vault.move('a.md', 'b.md', note.revision), /already exists/);
const trash = vault.remove('a.md', note.revision); assert.throws(() => vault.restore(trash.trashId, 'b.md'), /already exists/);
});
test('read pages recover every byte, survive JSON rendering and detect changes', t => {
const { vault, root } = fixture(t); vault.initialize();
const content = ('hello 😀\n\t"\\'.repeat(500)) + 'THE END';
fs.writeFileSync(path.join(root, 'long.md'), content);
let offset = 0; let revision; let recovered = '';
do {
const page = vault.execute({ action: 'read', path: 'long.md', offset, revision });
assert.ok(JSON.stringify(page).length < 16000);
recovered += page.content; revision = page.revision; offset = page.nextOffset;
assert.equal(page.complete, offset === null);
} while (offset !== null);
assert.equal(recovered, content);
fs.appendFileSync(path.join(root, 'long.md'), '!');
assert.throws(() => vault.read('long.md', 'utf8', { offset: 1024, revision }), /Revision conflict/);
assert.throws(() => vault.read('long.md', 'utf8', { offset: -1 }), /Invalid read page/);
const binary = Buffer.alloc(5000, 255); fs.writeFileSync(path.join(root, 'blob.bin'), binary);
const parts = []; offset = 0;
do { const p = vault.read('blob.bin', 'base64', { offset }); parts.push(Buffer.from(p.content, 'base64')); offset = p.nextOffset; } while (offset !== null);
assert.deepEqual(Buffer.concat(parts), binary);
});
test('listing and memory recall continue beyond the first page and search note tails', t => {
const { vault } = fixture(t); vault.initialize();
for (let i = 0; i < 25; i++) vault.write(`note-${String(i).padStart(2, '0')}.md`, 'x'.repeat(3000) + 'remember-me');
let offset = 0; const matches = [];
do { const page = vault.execute({ action: 'memory_search', query: 'remember-me', offset }); matches.push(...page.matches); offset = page.nextOffset; } while (offset !== null);
assert.equal(matches.length, 25);
assert.equal(new Set(matches.map(m => m.path)).size, 25);
});