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:
@@ -888,4 +888,3 @@ func TestSyncArtistDiscography_ResyncWithNotifications(t *testing.T) {
|
||||
t.Errorf("expected 0 notifications after resync, got %d", count)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
db := newTestDB(t)
|
||||
defer db.Close()
|
||||
|
||||
@@ -8,11 +8,11 @@ import (
|
||||
|
||||
func TestSimilarity(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
a string
|
||||
b string
|
||||
want float64
|
||||
epsilon float64
|
||||
name string
|
||||
a string
|
||||
b string
|
||||
want float64
|
||||
epsilon float64
|
||||
}{
|
||||
{
|
||||
name: "exact match scores 1.0",
|
||||
@@ -127,14 +127,14 @@ func TestFindMissingReleases(t *testing.T) {
|
||||
artistB := "artist-b"
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
local []database.LocalAlbum
|
||||
name string
|
||||
local []database.LocalAlbum
|
||||
external []database.ExternalRelease
|
||||
want []string // RGIDs expected to be reported as missing
|
||||
want []string // RGIDs expected to be reported as missing
|
||||
}{
|
||||
{
|
||||
name: "no local albums means all external are missing",
|
||||
local: nil,
|
||||
name: "no local albums means all external are missing",
|
||||
local: nil,
|
||||
external: []database.ExternalRelease{
|
||||
{RGID: "rg1", ArtistID: artistA, Title: "The Wall"},
|
||||
{RGID: "rg2", ArtistID: artistA, Title: "Animals"},
|
||||
|
||||
Reference in New Issue
Block a user