sonda/internal/api/http/router_test.go
tgiachi af933ad9ea feat(lidarr): a page of the artists I sent to Lidarr, and whether they arrived
Sonda kept no record of what an admin sent to Lidarr. Each send is now kept
(migration 0033, lidarr_requests), once for each artist, with the first date.
GET /lidarr/requests lists them newest first and says for each whether its
music is in the library: it is noticed when the list is read, by the artist
that was sent or by an artist of the same name that a scan made, and the day
it first was is kept.

The web app has a Requests page for admins, under Discover in the menu and on
Home on a phone, with the waiting and the arrived artists apart.
2026-11-15 12:32:29 +01:00

38 lines
1.1 KiB
Go

package httpapi
import (
"strings"
"testing"
"go.uber.org/zap"
)
// A route whose service was never wired panics on its first request, long after the server
// started. NewRouter refuses to build instead, naming what is missing.
func TestNewRouterRefusesAMissingDependency(t *testing.T) {
defer func() {
r := recover()
msg, _ := r.(string)
if !strings.Contains(msg, "CoversJob") {
t.Errorf("recovered %v, want a panic that names the missing CoversJob", r)
}
}()
d := Deps{Logger: zap.NewNop()}
NewRouter(d)
}
func TestNewRouterNamesEveryMissingDependency(t *testing.T) {
missing := missingDeps(Deps{Logger: zap.NewNop()})
for _, want := range []string{"Auth", "Tokens", "Listening", "CoversJob", "ArtistImagesJob", "DescriptionsJob", "Lidarr", "LidarrArtists", "LidarrRequests", "ArtistImages", "About", "Streams"} {
found := false
for _, m := range missing {
found = found || m == want
}
if !found {
t.Errorf("%s is not reported as missing: %v", want, missing)
}
}
if got := missingDeps(Deps{}); len(got) == 0 {
t.Error("an empty Deps has nothing missing")
}
}