; lib/blogimport/tests/verify.sx — shadow-diff at rest (round-trip parity) (st-bootstrap-classes!) (content-bootstrap-blocks!) (content-bootstrap-doc!) (content-bootstrap-callout!) (content-bootstrap-media!) (define p1 {:id "post-1" :slug "hello" :title "Hello" :status "published" :visibility "public" :tags (list "news") :authors (list "u1") :lexical {:root {:children (list {:type "heading" :tag "h2" :children (list {:type "text" :text "Title"})} {:type "paragraph" :children (list {:type "text" :text "plain "} {:type "text" :text "bold" :format 1})} {:type "list" :listType "number" :children (list {:type "listitem" :children (list {:type "text" :text "one"})} {:type "listitem" :children (list {:type "text" :text "two"})})} {:type "image" :src "/c.png" :alt "cat"})}}}) (define px {:id "post-x" :slug "ghost" :title "Ghost" :status "published" :lexical {:children (list {:type "paragraph" :children (list {:type "text" :text "never imported"})})}}) ; ---- happy path: replayed == oracle ---- (define B (persist/open)) (blogimport/import-post! B p1 10) (define v1 (blogimport/verify-post B p1)) (bi-test "verify ok" (get v1 :ok) true) (bi-test "verify block-ok" (get v1 :block-ok) true) (bi-test "verify meta-ok" (get v1 :meta-ok) true) ; ---- oracle block model is what we expect (inline bold flattened) ---- (define orc (blogimport/oracle p1)) (bi-test "oracle types" (get (get orc :blocks) :types) (list "heading" "text" "list" "image")) (bi-test "oracle contents" (get (get orc :blocks) :contents) (list "Title" "plain bold" (list "one" "two") "/c.png")) ; ---- corruption is DETECTED (op-log diverges from oracle) ---- (content/commit! B "post-1" (op-update "b1" "text" "CORRUPTED") 100) (define v2 (blogimport/verify-post B p1)) (bi-test "verify detects corruption" (get v2 :ok) false) (bi-test "verify corruption is block-level" (get v2 :block-ok) false) ; ---- an un-imported post fails verification (empty replay vs non-empty oracle) ---- (bi-test "unimported not ok" (get (blogimport/verify-post B px) :ok) false) ; ---- verify-all coverage scoreboard ---- (define B3 (persist/open)) (blogimport/import-post! B3 p1 10) (define cov (blogimport/verify-all B3 (list p1 px))) (bi-test "verify-all total" (get cov :total) 2) (bi-test "verify-all ok count" (get cov :ok) 1) (bi-test "verify-all mismatched" (get cov :mismatched) (list "post-x"))