fix(storage): type not found errors (#27265)

This commit is contained in:
Shoubhit Dash
2026-05-13 12:25:04 +05:30
committed by GitHub
parent d93a06431e
commit e9a29e4908
6 changed files with 51 additions and 21 deletions

View File

@@ -74,20 +74,23 @@ describe("Storage", () => {
it.live("maps missing reads to NotFoundError", () =>
Effect.gen(function* () {
const { root, svc } = yield* scope()
const exit = yield* svc.read([...root, "missing", "value"]).pipe(Effect.exit)
expect(Exit.isFailure(exit)).toBe(true)
const error = yield* Effect.flip(svc.read([...root, "missing", "value"]))
expect(error).toBeInstanceOf(Storage.NotFoundError)
expect(error._tag).toBe("NotFoundError")
expect(error.message).toContain(path.join(...root, "missing", "value") + ".json")
}),
)
it.live("update on missing key throws NotFoundError", () =>
Effect.gen(function* () {
const { root, svc } = yield* scope()
const exit = yield* svc
.update<{ value: number }>([...root, "missing", "key"], (draft) => {
const error = yield* Effect.flip(
svc.update<{ value: number }>([...root, "missing", "key"], (draft) => {
draft.value += 1
})
.pipe(Effect.exit)
expect(Exit.isFailure(exit)).toBe(true)
}),
)
expect(error).toBeInstanceOf(Storage.NotFoundError)
expect(error._tag).toBe("NotFoundError")
}),
)