Fix integration test bug: premature response body close

Fixed critical bug in TestScanProgress_BatchingWorks integration test where
response body was closed before JSON decoding, causing test failure.

Bug Location: Line 604 in scanner_integration_test.go example code

Problem:
  scanResp, err := client.Do(scanReq)
  require.NoError(s.T(), err)
  scanResp.Body.Close()  //  Closed here

  var scanResponse map[string]interface{}
  json.NewDecoder(scanResp.Body).Decode(&scanResponse)  //  Reads from closed body

Fix:
  scanResp, err := client.Do(scanReq)
  require.NoError(s.T(), err)

  var scanResponse map[string]interface{}
  json.NewDecoder(scanResp.Body).Decode(&scanResponse)
  scanResp.Body.Close()  //  Close AFTER decoding

This matches the pattern used in TestScanProgress_TracksStatistics and ensures
the response body is available for JSON decoding before being closed.

The implementation plan is now fully correct and ready for execution.
This commit is contained in:
2026-02-25 10:47:14 -05:00
parent 4a436f414c
commit 88844670af
+1 -1
View File
@@ -601,10 +601,10 @@ func (s *ScannerIntegrationTestSuite) TestScanProgress_BatchingWorks() {
scanResp, err := client.Do(scanReq)
require.NoError(s.T(), err)
scanResp.Body.Close()
var scanResponse map[string]interface{}
json.NewDecoder(scanResp.Body).Decode(&scanResponse)
scanResp.Body.Close()
jobID, ok := scanResponse["job_id"].(string)
require.True(s.T(), ok, "job_id should be string")