package memoriatest import ( "context" "testing" "amadan.net/oficina/memoria/internal/memoria/notion" ) // TestContainersAreNotCountedAsPages. // // A data source is a container, not a document. Ledgering one gave it a // row that stayed "pending" forever, counted it in the run's total, and // counted it as "already up to date" on every later run — so the status // page said "1 of 2 known pages imported" permanently, about a workspace // that was completely imported. A number that can never reach its own // denominator is the same lie as a confident zero, told the other way up. // // Found by a code review. // // MUTATION-TESTED 2026-09-05: removing the container guard around // SeeSourcePage in Syncer.walk makes this fail with 1 of 2. Reverted. func TestContainersAreNotCountedAsPages(t *testing.T) { src := newSource() src.roots = append(src.roots, notion.Ref{ ID: "db1", Title: "Projects", EditedTime: "t1", Kind: notion.KindDataSource, DataSourceID: "db1", }) src.children["db1"] = []notion.Ref{{ ID: "row1", Title: "Project Bluebird", Path: []string{"Projects"}, EditedTime: "t1", Kind: notion.KindPage, }} src.bodies["row1"] = "Status: Shipped. The deal closed in March." h, app, cid, _ := connectorApp(t, src) sync(t, h, app, cid) sync(t, h, app, cid) total, imported, err := app.Store().CountPages(context.Background(), cid) if err != nil { t.Fatal(err) } if total != imported { t.Errorf("%d of %d imported: a container is sitting in the ledger as a page that "+ "can never import, so this number can never reach its own denominator", imported, total) } if total != 1 { t.Errorf("ledger holds %d rows, want 1 — the row, not the database", total) } }