feat: verify scanner engine acceptance criteria

Confirm normalization + 0.85 threshold, IsIgnored skip, per-artist scoping,
and zero-threshold→default contract. Added TestScanArtist_ZeroThresholdUsesDefault,
fixed gofmt on two test files. Coverage: scanner 90.3%, normalize 100.0%.
This commit is contained in:
2026-07-19 18:21:51 +03:00
parent c2da8c2095
commit 9fc89fd5a4
4 changed files with 39 additions and 16 deletions

View File

@@ -84,11 +84,11 @@
- [x] run full test suite (`go test ./...`) and `go vet ./...` — must pass before final task - [x] run full test suite (`go test ./...`) and `go vet ./...` — must pass before final task
### Task 6: Verify acceptance criteria ### Task 6: Verify acceptance criteria
- [ ] verify `FindMissingReleases`/`ScanArtist`/`ScanAll` meet spec: normalization + 0.85 fuzzy threshold, ignore `IsIgnored`, per-artist scoping - [x] verify `FindMissingReleases`/`ScanArtist`/`ScanAll` meet spec: normalization + 0.85 fuzzy threshold, ignore `IsIgnored`, per-artist scoping (confirmed via tests in scanner_test.go / scan_test.go; grep of diff.go + scan.go shows normalizing via normalize.NormalizeString, IsIgnored skip, ArtistID grouping)
- [ ] verify `config.Scanner.FuzzyThreshold` default 0.85 is used when threshold arg is zero (or document the chosen contract) - [x] verify `config.Scanner.FuzzyThreshold` default 0.85 is used when threshold arg is zero (resolveThreshold in scanner.go returns DefaultThreshold=0.85 on zero; TestScanArtist_ZeroThresholdUsesDefault asserts zero==explicit default)
- [ ] run full test suite (unit) — all green - [x] run full test suite (unit) — all green (`go test ./...` passes)
- [ ] run `go vet ./...` and `gofmt -l ./internal ./cmd` — zero issues - [x] run `go vet ./...` and `gofmt -l ./internal ./cmd` — zero issues (fixed two unformatted test files)
- [ ] verify test coverage of `internal/scanner` and `internal/normalize` (target 80%+) - [x] verify test coverage of `internal/scanner` and `internal/normalize` (target 80%+) — scanner 90.3%, normalize 100.0%
### Task 7: Update documentation ### Task 7: Update documentation
- [ ] update `README.md` to note the Scanner Engine is implemented (compute-only; notifier/web pending) - [ ] update `README.md` to note the Scanner Engine is implemented (compute-only; notifier/web pending)

View File

@@ -888,4 +888,3 @@ func TestSyncArtistDiscography_ResyncWithNotifications(t *testing.T) {
t.Errorf("expected 0 notifications after resync, got %d", count) t.Errorf("expected 0 notifications after resync, got %d", count)
} }
} }

View File

@@ -82,6 +82,30 @@ func TestScanArtist(t *testing.T) {
} }
} }
func TestScanArtist_ZeroThresholdUsesDefault(t *testing.T) {
db := newTestDB(t)
defer db.Close()
seedArtist(t, db, "artist-1", "Pink Floyd")
seedLocalAlbum(t, db, "l1", "artist-1", "The Wall")
seedExternalRelease(t, db, "rg1", "artist-1", "The Wall", false)
seedExternalRelease(t, db, "rg2", "artist-1", "Animals", false)
// Pass 0 (zero value / unset) and the explicit default; results must match.
zero, err := ScanArtist(context.Background(), db, "artist-1", 0)
if err != nil {
t.Fatalf("ScanArtist(0) error: %v", err)
}
explicit, err := ScanArtist(context.Background(), db, "artist-1", DefaultThreshold)
if err != nil {
t.Fatalf("ScanArtist(%v) error: %v", DefaultThreshold, err)
}
if len(zero) != len(explicit) {
t.Errorf("ScanArtist(0) returned %d missing, ScanArtist(%v) returned %d; must match",
len(zero), DefaultThreshold, len(explicit))
}
}
func TestScanArtist_IgnoredNotReported(t *testing.T) { func TestScanArtist_IgnoredNotReported(t *testing.T) {
db := newTestDB(t) db := newTestDB(t)
defer db.Close() defer db.Close()