fix: address code review findings
- Strip standalone reissue keywords (remaster/remastered/remix/deluxe/ expanded/edition/reissue/anniversary/bonus) regardless of brackets so non-parenthesized remasters still match the plain local title above the 0.85 threshold (was falsely reported missing). - Fix TestAppRun_ScanLogsMissingReleases to verify run() performs the scan itself (capture its log output) instead of re-running ScanAll independently, which passed even if run() were a no-op. - Fix TestSimilarity misleading cases that downgraded to a <0.85 range check with dead want/epsilon fields; assert actual computed scores.
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"naviwatcher/internal/config"
|
||||
"naviwatcher/internal/database"
|
||||
"naviwatcher/internal/scanner"
|
||||
)
|
||||
|
||||
func TestAppRun_ScanLogsMissingReleases(t *testing.T) {
|
||||
@@ -54,6 +56,13 @@ func TestAppRun_ScanLogsMissingReleases(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
// Capture run()'s log output so we assert that run() ITSELF performed
|
||||
// the scan (not a separately re-run ScanAll). This guards against the
|
||||
// hook silently becoming a no-op while still passing.
|
||||
var buf bytes.Buffer
|
||||
log.SetOutput(&buf)
|
||||
defer log.SetOutput(os.Stderr)
|
||||
|
||||
// Run the (blocking) hook in a goroutine; cancel after it has had time to
|
||||
// perform the scan so run() returns nil via the ctx.Done() path.
|
||||
done := make(chan error, 1)
|
||||
@@ -66,15 +75,10 @@ func TestAppRun_ScanLogsMissingReleases(t *testing.T) {
|
||||
t.Fatalf("app.run() returned error: %v", err)
|
||||
}
|
||||
|
||||
// The scan should have found the missing release (Animals) for artist-1.
|
||||
// Use a fresh context for the verification scan since the run context was
|
||||
// cancelled above.
|
||||
missing, err := scanner.ScanAll(context.Background(), db, 0.85)
|
||||
if err != nil {
|
||||
t.Fatalf("ScanAll() error: %v", err)
|
||||
}
|
||||
if len(missing) != 1 || missing[0].RGID != "rg2" {
|
||||
t.Fatalf("expected 1 missing release (rg2/Animals), got %+v", missing)
|
||||
// run() must have logged the missing release (Animals) for artist-1.
|
||||
out := buf.String()
|
||||
if !strings.Contains(out, "missing: artist=artist-1") || !strings.Contains(out, "Animals") {
|
||||
t.Fatalf("app.run() did not log the expected missing release; log output:\n%s", out)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user