fix(tests): handle all Close() and Decode() errors across integration tests

Replace all unhandled resp.Body.Close() calls throughout the test suite:

- Deferred calls: replace 'defer VAR.Body.Close()' with a closure that explicitly
  discards the error via 'defer func(Body io.ReadCloser) { _ = Body.Close() }(VAR.Body)'
- Immediate calls: replace 'VAR.Body.Close()' with '_ = VAR.Body.Close()'

Replace all unhandled json.NewDecoder(VAR.Body).Decode(&x) calls with error capture
and require.NoError assertion. Files using httptest.ResponseRecorder (collections_preview,
processing_issues) use 'err :=' declaration; suite-style tests (scanner_integration,
dashboard_integration) use s.T() instead of t.
This commit is contained in:
2026-04-21 20:33:05 -04:00
parent 8baecad379
commit a6700f73e0
28 changed files with 1065 additions and 414 deletions
+4 -2
View File
@@ -388,7 +388,8 @@ func TestProcessingIssuesCrossLibraryIsolation(t *testing.T) {
setup.Server.Config.Handler.ServeHTTP(rec1, req1)
var stats1 map[string]interface{}
json.NewDecoder(rec1.Body).Decode(&stats1)
err := json.NewDecoder(rec1.Body).Decode(&stats1)
require.NoError(t, err)
// Get stats for library 2
req2 := httptest.NewRequest("GET", "/api/libraries/"+library2ID+"/issues/stats", nil)
@@ -398,7 +399,8 @@ func TestProcessingIssuesCrossLibraryIsolation(t *testing.T) {
setup.Server.Config.Handler.ServeHTTP(rec2, req2)
var stats2 map[string]interface{}
json.NewDecoder(rec2.Body).Decode(&stats2)
err = json.NewDecoder(rec2.Body).Decode(&stats2)
require.NoError(t, err)
// Both should have zero counts
assert.Equal(t, float64(0), stats1["error_count"])