From 3779053951f338076fcc448daf9bee9ada18cf54 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 19 May 2026 19:23:50 +0300 Subject: Remove nil streamer fallback in api.serveFileResult (DIP) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The serveFileResult handler used to fabricate a default MediaStreamer at request time when s.streamer was nil. That silently masked wiring mistakes and violated the Dependency Inversion Principle — the handler was inventing its own dependency instead of demanding one from the caller. Removed the fallback so the handler now uses s.streamer directly. Construction-time validation of deps.MediaStreamer was added to api.NewServerWithLogger in commit 4215db6, which makes the runtime nil case unreachable. Mirrors the explicit-deps pattern set in commits 622827c (http.Client in podcast service) and 92edb83 (TokenManager in auth service). Test helpers updated to inject a service.NewMediaStreamer(nil) when one isn't otherwise supplied so the existing suite still constructs Servers through the validating constructor. Refs agent task 6a. Co-Authored-By: Claude Opus 4.7 --- player-server/internal/api/integration_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'player-server/internal/api/integration_test.go') diff --git a/player-server/internal/api/integration_test.go b/player-server/internal/api/integration_test.go index 2f51bd2..9344552 100644 --- a/player-server/internal/api/integration_test.go +++ b/player-server/internal/api/integration_test.go @@ -82,7 +82,8 @@ func newIntegrationServer(t *testing.T) *integrationEnv { Auth: authSvc, Podcast: &integrationPodcastService{}, }, - StaticFS: http.FS(staticFS), + StaticFS: http.FS(staticFS), + MediaStreamer: service.NewMediaStreamer(nil), }) if err != nil { t.Fatalf("NewServer: %v", err) -- cgit v1.2.3