test fix
CI / check (push) Failing after 26s
CI / docker (push) Has been skipped

This commit is contained in:
Connor Johnstone
2026-04-01 22:47:09 -04:00
parent beb80b8770
commit e198643c57
+16 -6
View File
@@ -85,13 +85,23 @@ fn test_score_tracks_basic() {
let scored = score_tracks(&artists, &tracks_map, &top_map, 5, 0, None); let scored = score_tracks(&artists, &tracks_map, &top_map, 5, 0, None);
// Should have 3 tracks (only ones matching top tracks) // All 5 tracks should be included (unmatched get a small base score)
assert_eq!(scored.len(), 3); assert_eq!(scored.len(), 5);
// Higher playcount should yield higher score // Matched tracks should score higher than unmatched ones
let scores: Vec<f64> = scored.iter().map(|t| t.score).collect(); let mut matched: Vec<f64> = scored
let max_score = scores.iter().cloned().fold(f64::NEG_INFINITY, f64::max); .iter()
assert!(max_score > 0.0); .filter(|t| t.title.as_deref().is_some_and(|n| n.starts_with("Song 1") || n.starts_with("Song 2") || n.starts_with("Song 3")))
.map(|t| t.score)
.collect();
let mut unmatched: Vec<f64> = scored
.iter()
.filter(|t| t.title.as_deref().is_some_and(|n| n.starts_with("Song 4") || n.starts_with("Song 5")))
.map(|t| t.score)
.collect();
matched.sort_by(|a, b| b.partial_cmp(a).unwrap());
unmatched.sort_by(|a, b| b.partial_cmp(a).unwrap());
assert!(matched[0] > unmatched[0], "matched tracks should score higher than unmatched");
} }
#[test] #[test]