This commit is contained in:
ponzischeme89
2026-08-11 23:41:10 +12:00
parent 0e183cf560
commit 5fed3360c2
42 changed files with 1340 additions and 130 deletions
+40
View File
@@ -0,0 +1,40 @@
package api
import (
"testing"
"github.com/ponzischeme89/memby/server/internal/sonarr"
)
func TestSonarrSeriesStatusKeyPrefersTVDBIdentity(t *testing.T) {
series := sonarr.Series{ID: 42, TVDBID: 1234}
if got := sonarrSeriesStatusKey(series); got != "tvdb:1234" {
t.Fatalf("status key = %q, want tvdb:1234", got)
}
series.TVDBID = 0
if got := sonarrSeriesStatusKey(series); got != "sonarr:42" {
t.Fatalf("fallback status key = %q, want sonarr:42", got)
}
}
func TestSonarrCancellationRequiresAnActiveHistory(t *testing.T) {
for _, transition := range [][2]string{
{"continuing", "ended"},
{"upcoming", "deleted"},
{"Continuing", "cancelled"},
} {
if !sonarrBecameCancelled(transition[0], transition[1]) {
t.Errorf("%q -> %q should be a cancellation", transition[0], transition[1])
}
}
for _, transition := range [][2]string{
{"", "ended"}, // first scan is a baseline, not news
{"ended", "ended"}, // an unchanged cancelled show is not announced daily
{"ended", "continuing"},
{"continuing", "continuing"},
} {
if sonarrBecameCancelled(transition[0], transition[1]) {
t.Errorf("%q -> %q should not be a cancellation", transition[0], transition[1])
}
}
}