package mediawire import ( "context" "errors" "net" "testing" ) // R-1060 — the library wiring and the sessions call Plex by ADDRESS (productionURL), resolved at every call; every // other app stays by name. COMPANION RED-PROOF: drop the plex case in productionURL → „http://plex:32400" and this fails. func TestR1060_ProductionURLCallsPlexByAddress(t *testing.T) { old := PlexLookup t.Cleanup(func() { PlexLookup = old }) calls := 0 PlexLookup = func(context.Context) ([]net.IPAddr, error) { calls++ return []net.IPAddr{{IP: net.ParseIP("fd00::5")}, {IP: net.ParseIP("172.18.0.15")}}, nil } url := productionURL(nil) if got := url("plex", 32400); got != "http://172.18.0.15:32400" { t.Fatalf("plex → %q, want its IPv4 address", got) } _ = url("plex", 32400) if calls != 2 { t.Fatalf("resolved %d times for 2 calls — the address must be resolved at each call, never cached", calls) } if got := url("sonarr", 8989); got != "http://sonarr:8989" { t.Fatalf("sonarr → %q, other apps stay by name", got) } PlexLookup = func(context.Context) ([]net.IPAddr, error) { return nil, errors.New("no such host") } if got := url("plex", 32400); got != "http://plex:32400" { t.Fatalf("an unresolvable plex falls back to the name (logged), got %q", got) } }