Artifact 22ead49914f214b97f5632f6c393bb116d29cde6cf86132d2aef39d942b007bc:
- File
repo_partial_mirror_test.go
— part of check-in
[6012d82bd6]
at
2026-10-21 11:45:38
on branch feat/submanifest-reader
— feat(sync): serve partial-mirror clones from the partial-mirror setting
A sparse store refuses a clone its cone does not cover unless the boolean partial-mirror repository setting is on, read as fossil reads a boolean setting. It reaches HandleSync, XferHandler, ServeHTTP and repo serve alike; libfossil.SettingPartialMirror names it. Closes SC-5.3-2. (user: [email protected], size: 1548) [annotate] [blame] [check-ins using] [more...]
package libfossil import ( "context" "path/filepath" "strings" "testing" ) // The partial-mirror setting is the public switch for ยง5.3's clone-origin // refusal: unset, a sparse store refuses a dense clone; set, it serves one. func TestPartialMirrorSettingDrivesCloneRefusal(t *testing.T) { source, err := Create(filepath.Join(t.TempDir(), "source.fossil"), CreateOpts{User: "test"}) if err != nil { t.Fatal(err) } defer source.Close() if _, _, err := source.Commit(CommitOpts{User: "test", Files: []FileToCommit{ {Name: "src/a", Content: []byte("inside\n")}, {Name: "zzz/b", Content: []byte("outside\n")}, }}); err != nil { t.Fatal(err) } c, err := NewCone([]string{"src"}, nil) if err != nil { t.Fatal(err) } if err := source.SetStoreCone(c); err != nil { t.Fatal(err) } peer := TransportFunc(func(ctx context.Context, payload []byte) ([]byte, error) { return source.HandleSync(ctx, payload) }) for _, setting := range []string{"", "off", "on"} { if setting != "" { if err := source.SetConfig(SettingPartialMirror, setting); err != nil { t.Fatal(err) } } clone, _, err := Clone(context.Background(), filepath.Join(t.TempDir(), "clone-"+setting+".fossil"), peer, CloneOpts{}) if setting != "on" { if err == nil || !strings.Contains(err.Error(), "configure a partial mirror") { t.Fatalf("partial-mirror=%q: clone error = %v, want the origin refusal", setting, err) } continue } if err != nil { t.Fatalf("partial-mirror=on: clone refused: %v", err) } clone.Close() } }