test(library): the volume-absent refusals are tested apart from the mark cap (#8296)
release / web (push) Successful in 1m40s
release / go (push) Failing after 2m7s
release / govulncheck (push) Successful in 21s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Publish the release image to GHCR (dispatch only) (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / android (push) Canceled after 1m2s
release / Build signed APK (push) Canceled after 23s
release / integration (push) Canceled after 2m48s
release / web (push) Successful in 1m40s
release / go (push) Failing after 2m7s
release / govulncheck (push) Successful in 21s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Publish the release image to GHCR (dispatch only) (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / android (push) Canceled after 1m2s
release / Build signed APK (push) Canceled after 23s
release / integration (push) Canceled after 2m48s
Every case marked every track, so the 25% cap refused before the root checks were reached: run 11272 broke the empty-root check and the test still passed. The walk now marks one track of ten and clears a returned one, which reconcile would do, so only the root and empty-walk checks can refuse it; and the test asserts nothing was cleared either, since those checks run before restores. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -255,34 +255,44 @@ func TestReconcileMissing_ClearsEvenWhenMarkCapTrips(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// A walk that cannot be trusted marks nothing: one that saw no files, a root
|
// A walk that cannot be trusted changes nothing, neither marking nor clearing:
|
||||||
// that is not mounted (absent), a mount point with nothing on it (present but
|
// one that saw no files, a root that is not mounted (absent), a mount point
|
||||||
// empty, which os.Stat alone would pass), one detached root among several,
|
// with nothing on it (present but empty, which os.Stat alone would pass), one
|
||||||
// or no roots configured at all.
|
// detached root among several, or no roots configured at all. The walk below
|
||||||
|
// would otherwise mark one track of ten, under missingMarkMaxFraction, and
|
||||||
|
// clear a returned one, so only these checks can refuse it.
|
||||||
func TestReconcileMissing_RefusesWhenAVolumeLooksAbsent(t *testing.T) {
|
func TestReconcileMissing_RefusesWhenAVolumeLooksAbsent(t *testing.T) {
|
||||||
seenSomething := map[string]struct{}{"/x": {}}
|
rows := []dbq.ListTrackPathsForReconcileRow{row(99, "/music/back.mp3", true)}
|
||||||
|
walked := map[string]struct{}{"/music/back.mp3": {}}
|
||||||
|
for i := 0; i < 10; i++ {
|
||||||
|
p := fmt.Sprintf("/music/track-%02d.mp3", i)
|
||||||
|
rows = append(rows, row(byte(i), p, false))
|
||||||
|
if i > 0 {
|
||||||
|
walked[p] = struct{}{}
|
||||||
|
}
|
||||||
|
}
|
||||||
for _, tc := range []struct {
|
for _, tc := range []struct {
|
||||||
name string
|
name string
|
||||||
roots func(t *testing.T) []string
|
roots func(t *testing.T) []string
|
||||||
seen map[string]struct{}
|
seen map[string]struct{}
|
||||||
}{
|
}{
|
||||||
{"the walk saw no files", func(t *testing.T) []string { return []string{populatedRoot(t)} }, map[string]struct{}{}},
|
{"the walk saw no files", func(t *testing.T) []string { return []string{populatedRoot(t)} }, map[string]struct{}{}},
|
||||||
{"a root is absent", func(t *testing.T) []string { return []string{filepath.Join(t.TempDir(), "not-mounted")} }, seenSomething},
|
{"a root is absent", func(t *testing.T) []string { return []string{filepath.Join(t.TempDir(), "not-mounted")} }, walked},
|
||||||
{"a root is empty", func(t *testing.T) []string { return []string{t.TempDir()} }, seenSomething},
|
{"a root is empty", func(t *testing.T) []string { return []string{t.TempDir()} }, walked},
|
||||||
{"one of several roots is absent", func(t *testing.T) []string {
|
{"one of several roots is absent", func(t *testing.T) []string {
|
||||||
return []string{populatedRoot(t), filepath.Join(t.TempDir(), "detached")}
|
return []string{populatedRoot(t), filepath.Join(t.TempDir(), "detached")}
|
||||||
}, seenSomething},
|
}, walked},
|
||||||
{"no roots configured", func(*testing.T) []string { return nil }, seenSomething},
|
{"no roots configured", func(*testing.T) []string { return nil }, walked},
|
||||||
} {
|
} {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
s := testScanner(t, tc.roots(t)...)
|
s := testScanner(t, tc.roots(t)...)
|
||||||
q := &fakeReconciler{rows: []dbq.ListTrackPathsForReconcileRow{row(1, "/music/a.mp3", false)}}
|
q := &fakeReconciler{rows: rows}
|
||||||
var stats Stats
|
var stats Stats
|
||||||
if err := s.reconcileMissing(context.Background(), q, tc.seen, &stats); err == nil {
|
if err := s.reconcileMissing(context.Background(), q, tc.seen, &stats); err == nil {
|
||||||
t.Fatal("reconcile went ahead; want a refusal")
|
t.Fatal("reconcile went ahead; want a refusal")
|
||||||
}
|
}
|
||||||
if len(q.marked) != 0 {
|
if len(q.marked) != 0 || len(q.cleared) != 0 {
|
||||||
t.Errorf("marked rows: %v", q.marked)
|
t.Errorf("marked %v, cleared %v; want nothing changed", q.marked, q.cleared)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user