test(jsonl): pin corruption and storage-fault rejection
Identity validation must reject a header id that cannot derive a path, and only ENOENT may mean that storage is absent. Other root or per-path failures must remain visible instead of becoming an empty list or false miss. Exercise those branches with narrow storage-mechanics cases, preserving per-file 100% coverage without restoring the flat-layout or multi-writer tests removed from the replacement design.
This commit is contained in:
1 file changed
+25
@@ -642,6 +642,16 @@ describe('SessionPersistenceJsonl: edge cases', () => {
|
||||
await expect(ctx.sessionPersistence.list()).rejects.toThrow(/and cwd belong at/)
|
||||
})
|
||||
|
||||
it('list rejects a session header whose id cannot name a storage path', async () => {
|
||||
const bucket = sessionDir(root, undefined)
|
||||
await mkdir(bucket, { recursive: true })
|
||||
await writeFile(join(bucket, 'invalid-id.jsonl'), JSON.stringify({
|
||||
type: 'session', version: 0, id: '', createdAt: 1,
|
||||
}) + '\n')
|
||||
|
||||
await expect(ctx.sessionPersistence.list()).rejects.toThrow(/header id cannot name a storage path/)
|
||||
})
|
||||
|
||||
it('load and list reject one id materialized in multiple cwd buckets', async () => {
|
||||
const id = SessionId('duplicate')
|
||||
for (const cwd of ['/a', '/b']) {
|
||||
@@ -757,6 +767,21 @@ describe('SessionPersistenceJsonl: edge cases', () => {
|
||||
await ctx2.fiber.dispose()
|
||||
})
|
||||
|
||||
it('list surfaces a root that becomes unusable after plugin load', async () => {
|
||||
await rm(root, { recursive: true })
|
||||
await writeFile(root, 'not a directory')
|
||||
|
||||
await expect(ctx.sessionPersistence.list()).rejects.toThrow(/ENOTDIR/)
|
||||
})
|
||||
|
||||
it('per-id lookup surfaces non-ENOENT storage errors', async () => {
|
||||
const blocker = join(root, 'not-a-directory')
|
||||
await writeFile(blocker, 'x')
|
||||
const backend = ctx.sessionPersistence as unknown as { exists(path: string): Promise<boolean> }
|
||||
|
||||
await expect(backend.exists(join(blocker, 'child.jsonl'))).rejects.toThrow(/ENOTDIR/)
|
||||
})
|
||||
|
||||
it('materialization surfaces a cwd-bucket storage fault', async () => {
|
||||
const cwd = '/x'
|
||||
const ctx2 = new Context()
|
||||
|
||||
Reference in New Issue
Block a user