diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-10 09:13:10 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-10 09:13:10 +0300 |
| commit | 83cd87a04f65229346cb4f77f56eba5da0c668c1 (patch) | |
| tree | 2166a8c70f0c674988976d5cc2b3ed1d17589d40 | |
| parent | 060de74e669fc8c7deed0c3f563581a3031d529c (diff) | |
fix(tests): handle json.Unmarshal errors explicitly in *_test.go
| -rw-r--r-- | internal/api/handlers_test.go | 12 |
1 files 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") } |
