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:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user