test: fix 4 integration-suite root causes surfaced by CI (C+A+B+F)
Latent failures exposed now that integration tests run in CI (#339). All test/test-harness only — no production code changes. A (dbtest.ResetDB): also truncate cover_art_provider_settings + cover_art_sources_meta. The monotonic source-version counter (seeded 1 by 0018) accumulated across internal/coverart tests → CurrentVersion=4 want 1, key-only-bump assertions, enricher source skips. SettingsService re-seeds both at boot, so a truncated start is the correct fresh state. B (playlists system_test.seedPlayEvent): inserted play_events with a random session_id → play_events_session_id_fkey violation (7 tests). Create the parent play_sessions row in the same statement (CTE). C (similarity worker_integration_test.newTestWorker): built the client with only BaseURL. Post-4fca0e6 similarity hits the Labs API via LabsBaseURL, so an unset LabsBaseURL fell through to the real labs.api and the stub never ran → 0 similarity rows. Set LabsBaseURL to the stub. F (library scanner_test): NOT a flake — deterministic. Synthetic ID3-only MP3s have no decodable duration; the scanner intentionally won't skip duration_ms=0 rows (retries duration backfill), so every re-scan reported Updated not Skipped. Seed duration_ms>0 before the second scan so the mtime-based incremental-skip path under test is actually exercised. Production scanner behavior unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -114,8 +114,11 @@ func markPlayed(t *testing.T, f fixture, trackID pgtype.UUID) {
|
||||
func newTestWorker(f fixture, lbBaseURL string) *Worker {
|
||||
logger := slog.New(slog.NewTextHandler(io.Discard, nil))
|
||||
return &Worker{
|
||||
pool: f.pool,
|
||||
client: &listenbrainz.Client{BaseURL: lbBaseURL, HTTP: http.DefaultClient},
|
||||
pool: f.pool,
|
||||
// LabsBaseURL must point at the stub too: similarity calls hit
|
||||
// the Labs API (commit 4fca0e6), so an unset LabsBaseURL would
|
||||
// fall through to the real labs.api and the stub never runs.
|
||||
client: &listenbrainz.Client{BaseURL: lbBaseURL, LabsBaseURL: lbBaseURL, HTTP: http.DefaultClient},
|
||||
logger: logger,
|
||||
tick: 1 * time.Hour,
|
||||
batch: 5,
|
||||
|
||||
Reference in New Issue
Block a user