package scrobble import "testing" // A play is scrobbled once it ran four minutes or half the track, whichever // comes first, the rule ListenBrainz and Last.fm both use. func TestQualifies(t *testing.T) { for _, tc := range []struct { playedMs int ratio float64 want bool }{ {0, 0, false}, {240_000, 0, true}, {0, 0.5, true}, {120_000, 0.49, false}, {239_999, 0.4999, false}, {240_000, 0.4999, true}, {239_999, 0.5, true}, } { if got := Qualifies(tc.playedMs, tc.ratio); got != tc.want { t.Errorf("Qualifies(%d ms, %.4f) = %v, want %v", tc.playedMs, tc.ratio, got, tc.want) } } }