Artifact 5d8aea5545952a3f8398e7dd291d513493e3b05365c69f4ac89672e34d995698:
- File
internal/repo/hash_policy_test.go
— part of check-in
[245a0ed306]
at
2026-10-20 02:08:49
on branch feat/submanifest-reader
— conformance: re-pin the three drafts to their -00 names
zit check-in 68a3f76cb7 renames the artifact-format, repo-state and sync-protocol drafts from -01 to -00 in their headers, cross-references and reference entries, and retitles each Changes appendix "Changes in This Revision". No normative text changed and no section number moved.
The pinned copies take zit's file names, the requirement tables pin the new hashes, and the comments, tests and docs that cited the -01 drafts cite the -00 ones. The refresh script copies every draft under its own name. The sparse-cone copy is re-pinned to d497c2432f, whose text is unchanged. Coverage counts are identical before and after. (user: [email protected], size: 2059) [annotate] [blame] [check-ins using] [more...]
package repo_test import ( "path/filepath" "testing" "github.com/danmestas/go-libfossil/internal/blob" "github.com/danmestas/go-libfossil/internal/repo" _ "github.com/danmestas/go-libfossil/internal/testdriver" "github.com/danmestas/go-libfossil/simio" ) func newRepo(t *testing.T) *repo.Repo { t.Helper() r, err := repo.Create(filepath.Join(t.TempDir(), "r.fossil"), "tester", simio.CryptoRand{}, "") if err != nil { t.Fatalf("repo.Create: %v", err) } t.Cleanup(func() { r.Close() }) return r } func storedPolicy(t *testing.T, r *repo.Repo) string { t.Helper() got, err := r.Config("hash-policy") if err != nil { t.Fatalf("Config: %v", err) } return got } // artifact-format-00 7.3: requesting auto once a SHA3 artifact exists stores // sha3, as fossil's hash-policy command does; without one, auto is stored. func TestSetHashPolicyCoercesAuto(t *testing.T) { for _, tt := range []struct { name string before string // policy content is stored under first; "" stores none want string }{ {"empty repo", "", "1"}, {"sha1 artifact", "sha1", "1"}, {"sha3 artifact", "sha3", "2"}, } { t.Run(tt.name, func(t *testing.T) { r := newRepo(t) if tt.before != "" { if err := r.SetHashPolicy(tt.before); err != nil { t.Fatalf("SetHashPolicy(%q): %v", tt.before, err) } if _, _, err := blob.Store(r.DB(), []byte("content")); err != nil { t.Fatalf("blob.Store: %v", err) } } if err := r.SetHashPolicy("auto"); err != nil { t.Fatalf("SetHashPolicy(auto): %v", err) } if got := storedPolicy(t, r); got != tt.want { t.Errorf("stored hash-policy = %q, want %q", got, tt.want) } }) } } // 7.3 has no demotion guard: sha1 may be set after sha3. func TestSetHashPolicyNoDemotionGuard(t *testing.T) { r := newRepo(t) for _, name := range []string{"shun-sha1", "sha1"} { if err := r.SetHashPolicy(name); err != nil { t.Fatalf("SetHashPolicy(%q): %v", name, err) } } if got := storedPolicy(t, r); got != "0" { t.Errorf("stored hash-policy = %q, want 0", got) } }