The first public release of Fabled Minstrel #158

Merged
bvandeusen merged 256 commits from dev into main 2026-12-03 21:41:58 -05:00
Showing only changes of commit 25c7db71b1 - Show all commits
+22 -12
View File
@@ -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
// that is not mounted (absent), a mount point with nothing on it (present but
// empty, which os.Stat alone would pass), one detached root among several,
// or no roots configured at all.
// A walk that cannot be trusted changes nothing, neither marking nor clearing:
// one that saw no files, a root that is not mounted (absent), a mount point
// with nothing on it (present but empty, which os.Stat alone would pass), one
// 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) {
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 {
name string
roots func(t *testing.T) []string
seen 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 empty", func(t *testing.T) []string { return []string{t.TempDir()} }, 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()} }, walked},
{"one of several roots is absent", func(t *testing.T) []string {
return []string{populatedRoot(t), filepath.Join(t.TempDir(), "detached")}
}, seenSomething},
{"no roots configured", func(*testing.T) []string { return nil }, seenSomething},
}, walked},
{"no roots configured", func(*testing.T) []string { return nil }, walked},
} {
t.Run(tc.name, func(t *testing.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
if err := s.reconcileMissing(context.Background(), q, tc.seen, &stats); err == nil {
t.Fatal("reconcile went ahead; want a refusal")
}
if len(q.marked) != 0 {
t.Errorf("marked rows: %v", q.marked)
if len(q.marked) != 0 || len(q.cleared) != 0 {
t.Errorf("marked %v, cleared %v; want nothing changed", q.marked, q.cleared)
}
})
}