persist: stream catalog — enumerate streams + 10 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 30s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 30s
New backend op :streams (from seq high-water marks, so compacted streams still list), threaded through mem-backend + durable serve/io-backend. catalog.sx: persist/streams, stream-count, stream-exists?, total-events. 143/143. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
86
lib/persist/tests/catalog.sx
Normal file
86
lib/persist/tests/catalog.sx
Normal file
@@ -0,0 +1,86 @@
|
||||
; Extension — stream catalog: enumerate streams, count, existence, totals.
|
||||
|
||||
(persist-test
|
||||
"empty backend has no streams"
|
||||
(persist/stream-count (persist/open))
|
||||
0)
|
||||
(persist-test
|
||||
"stream-exists? false when absent"
|
||||
(persist/stream-exists? (persist/open) "orders")
|
||||
false)
|
||||
(persist-test
|
||||
"append registers a stream"
|
||||
(let
|
||||
((b (persist/open)))
|
||||
(begin
|
||||
(persist/append b "orders" "x" 0 {})
|
||||
(persist/stream-exists? b "orders")))
|
||||
true)
|
||||
(persist-test
|
||||
"stream-count counts distinct streams"
|
||||
(let
|
||||
((b (persist/open)))
|
||||
(begin
|
||||
(persist/append b "a" "x" 0 {})
|
||||
(persist/append b "b" "x" 0 {})
|
||||
(persist/append b "a" "x" 0 {})
|
||||
(persist/stream-count b)))
|
||||
2)
|
||||
(persist-test
|
||||
"compacted-away stream still lists"
|
||||
(let
|
||||
((b (persist/open)))
|
||||
(begin
|
||||
(persist/append b "a" "x" 0 {})
|
||||
(persist/checkpoint b "a" "snap" (fn (acc e) acc) 0)
|
||||
(persist/truncate b "a" 1)
|
||||
(list (persist/count b "a") (persist/stream-exists? b "a"))))
|
||||
(list 0 true))
|
||||
(persist-test
|
||||
"kv-only backend lists no streams"
|
||||
(let
|
||||
((b (persist/open)))
|
||||
(begin (persist/kv-put b "k" 1) (persist/stream-count b)))
|
||||
0)
|
||||
(persist-test
|
||||
"total-events sums high-water marks"
|
||||
(let
|
||||
((b (persist/open)))
|
||||
(begin
|
||||
(persist/append b "a" "x" 0 {})
|
||||
(persist/append b "a" "x" 0 {})
|
||||
(persist/append b "b" "x" 0 {})
|
||||
(persist/total-events b)))
|
||||
3)
|
||||
(persist-test
|
||||
"total-events counts compacted events too"
|
||||
(let
|
||||
((b (persist/open)))
|
||||
(begin
|
||||
(persist/append b "a" "x" 0 {})
|
||||
(persist/append b "a" "x" 0 {})
|
||||
(persist/checkpoint b "a" "snap" (fn (acc e) acc) 0)
|
||||
(persist/truncate b "a" 2)
|
||||
(persist/total-events b)))
|
||||
2)
|
||||
(persist-test
|
||||
"catalog works on the durable backend"
|
||||
(let
|
||||
((db (persist/mock-durable (persist/mem-backend))))
|
||||
(begin
|
||||
(persist/append db "a" "x" 0 {})
|
||||
(persist/append db "b" "x" 0 {})
|
||||
(persist/stream-count db)))
|
||||
2)
|
||||
(persist-test
|
||||
"catalog survives restart"
|
||||
(let
|
||||
((disk (persist/mem-backend)))
|
||||
(begin
|
||||
(let
|
||||
((db (persist/mock-durable disk)))
|
||||
(begin
|
||||
(persist/append db "a" "x" 0 {})
|
||||
(persist/append db "b" "x" 0 {})))
|
||||
(persist/stream-count (persist/mock-durable disk))))
|
||||
2)
|
||||
Reference in New Issue
Block a user