Artifact fdbb023723f2bb4ad6ed0f4133933d1a4d887638e4a2b2dabe7716e98dd2581b:
- File
cli/repo_verify_test.go
— part of check-in
[168062ca33]
at
2026-10-21 16:43:34
on branch feat/submanifest-reader
— fix(cli): repo verify reports damage, transit phantoms and elision
repo verify hashed the held blobs and printed a fixed line. It now runs the full verifier the library uses for rebuild, prints each issue, and reports transit phantoms apart from elided artifacts, as sparse-cone 5.2 requires of a verification operation: a store complete within its cone verifies healthy and shows its elided count. (user: [email protected], size: 1646) [annotate] [blame] [check-ins using] [more...]
package cli import ( "context" "path/filepath" "strings" "testing" libfossil "github.com/danmestas/go-libfossil" ) // repo verify reports elided artifacts apart from damage and from transit // phantoms, and calls a store complete within its cone healthy // (sparse-cone ยง5.2). Method: commit inside and outside a cone, narrow the // store and compact it, then verify. func TestRepoVerifyReportsElided(t *testing.T) { path := filepath.Join(t.TempDir(), "repo.fossil") r, err := libfossil.Create(path, libfossil.CreateOpts{User: "u"}) if err != nil { t.Fatal(err) } if _, _, err := r.Commit(libfossil.CommitOpts{User: "u", Comment: "one", Files: []libfossil.FileToCommit{ {Name: "src/a.txt", Content: []byte("inside\n")}, {Name: "zzz/b.txt", Content: []byte("outside\n")}, }}); err != nil { t.Fatal(err) } if _, err := r.Inner().DB().Exec("DELETE FROM unsent"); err != nil { t.Fatal(err) } c, err := libfossil.NewCone([]string{"src"}, nil) if err != nil { t.Fatal(err) } if err := r.SetStoreCone(c); err != nil { t.Fatal(err) } if n, err := r.CompactStore(context.Background()); err != nil || n != 1 { t.Fatalf("compact = %d, %v; want 1", n, err) } if err := r.Close(); err != nil { t.Fatal(err) } var runErr error out := requiredHTTPStdout(t, func() error { runErr = (&RepoVerifyCmd{}).Run(&Globals{Repo: path}) return nil }) if runErr != nil { t.Fatalf("verify of a store complete within its cone: %v\n%s", runErr, out) } if !strings.Contains(out, "0 transit phantoms, 1 elided\n") || !strings.HasSuffix(out, "repository integrity verified\n") { t.Fatalf("verify output = %q", out) } }