返回 DeepSeek-Reasonix
ordinary_corrupt_test.go
根目录 / internal / sessioncatalog / ordinary_corrupt_test.go
1 package sessioncatalog
2
3 import (
4 "context"
5 "path/filepath"
6 "testing"
7 )
8
9 func TestOrdinaryViewsHideConfirmedDamageButRetainPendingRepair(t *testing.T) {
10 catalog, err := Open(t.Context(), Options{Path: filepath.Join(t.TempDir(), "catalog.sqlite"), MetadataOnly: true, DisableRepair: true})
11 if err != nil {
12 t.Fatal(err)
13 }
14 t.Cleanup(func() { _ = catalog.Close(context.Background()) })
15 dir := t.TempDir()
16 for _, health := range []Health{HealthOK, HealthDegraded, HealthCorrupt, HealthMissing} {
17 record := SessionRecord{Path: filepath.Join(dir, string(health)+".jsonl"), Directory: dir, Scope: "global", TopicID: string(health), Health: health, OrdinaryVisible: true}
18 if err := catalog.UpsertSession(t.Context(), record); err != nil {
19 t.Fatal(err)
20 }
21 want := health == HealthOK || health == HealthDegraded
22 if OrdinaryTreeSession(record, false, false, nil) != want {
23 t.Fatalf("materialized visibility for %s", health)
24 }
25 }
26 rows, err := catalog.ListOrdinarySessions(t.Context(), OrdinaryPageRequest{Scope: "global", Limit: 50})
27 if err != nil || len(rows) != 2 {
28 t.Fatalf("paged visibility: %+v %v", rows, err)
29 }
30 for _, row := range rows {
31 if row.Health == HealthCorrupt || row.Health == HealthMissing {
32 t.Fatal("damaged row shown")
33 }
34 }
35 }
36
36 lines GO