From 83cd87a04f65229346cb4f77f56eba5da0c668c1 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 10 May 2026 09:13:10 +0300 Subject: fix(tests): handle json.Unmarshal errors explicitly in *_test.go --- internal/api/handlers_test.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/internal/api/handlers_test.go b/internal/api/handlers_test.go index eaeb665..363b6ba 100644 --- a/internal/api/handlers_test.go +++ b/internal/api/handlers_test.go @@ -450,7 +450,9 @@ func TestServer_Login(t *testing.T) { t.Fatalf("expected %d, got %d", http.StatusOK, rr.Code) } var resp map[string]any - _ = json.Unmarshal(rr.Body.Bytes(), &resp) + if err := json.Unmarshal(rr.Body.Bytes(), &resp); err != nil { + t.Fatalf("unmarshal response: %v", err) + } if resp["username"] != "alice" { t.Fatalf("unexpected username") } @@ -834,7 +836,9 @@ func TestServer_Favorite(t *testing.T) { t.Fatalf("expected %d, got %d", http.StatusOK, rr.Code) } var resp map[string]bool - _ = json.Unmarshal(rr.Body.Bytes(), &resp) + if err := json.Unmarshal(rr.Body.Bytes(), &resp); err != nil { + t.Fatalf("unmarshal response: %v", err) + } if !resp["favorite"] { t.Fatal("expected favorite true") } @@ -1280,7 +1284,9 @@ func TestServer_ListSets(t *testing.T) { t.Fatalf("expected %d, got %d", http.StatusOK, rr.Code) } var sets []model.Set - _ = json.Unmarshal(rr.Body.Bytes(), &sets) + if err := json.Unmarshal(rr.Body.Bytes(), &sets); err != nil { + t.Fatalf("unmarshal response: %v", err) + } if len(sets) != 1 || sets[0].Name != "music" { t.Fatalf("unexpected sets response") } -- cgit v1.2.3