@@ -246,8 +246,10 @@ func TestPost_GitlabCommentNotAllowlisted(t *testing.T) {
246
246
w := httptest .NewRecorder ()
247
247
e .Post (w , req )
248
248
249
- Equals (t , http .StatusForbidden , w .Result ().StatusCode )
250
- body , _ := io .ReadAll (w .Result ().Body )
249
+ resp := w .Result ()
250
+ defer resp .Body .Close ()
251
+ Equals (t , http .StatusForbidden , resp .StatusCode )
252
+ body , _ := io .ReadAll (resp .Body )
251
253
exp := "Repo not allowlisted"
252
254
Assert (t , strings .Contains (string (body ), exp ), "exp %q to be contained in %q" , exp , string (body ))
253
255
expRepo , _ := models .NewRepo (models .Gitlab , "gitlabhq/gitlab-test" , "https://example.com/gitlabhq/gitlab-test.git" , "" , "" )
@@ -279,8 +281,10 @@ func TestPost_GitlabCommentNotAllowlistedWithSilenceErrors(t *testing.T) {
279
281
w := httptest .NewRecorder ()
280
282
e .Post (w , req )
281
283
282
- Equals (t , http .StatusForbidden , w .Result ().StatusCode )
283
- body , _ := io .ReadAll (w .Result ().Body )
284
+ resp := w .Result ()
285
+ defer resp .Body .Close ()
286
+ Equals (t , http .StatusForbidden , resp .StatusCode )
287
+ body , _ := io .ReadAll (resp .Body )
284
288
exp := "Repo not allowlisted"
285
289
Assert (t , strings .Contains (string (body ), exp ), "exp %q to be contained in %q" , exp , string (body ))
286
290
vcsClient .VerifyWasCalled (Never ()).CreateComment (Any [logging.SimpleLogging ](), Any [models.Repo ](), Any [int ](), Any [string ](), Any [string ]())
@@ -311,8 +315,10 @@ func TestPost_GithubCommentNotAllowlisted(t *testing.T) {
311
315
w := httptest .NewRecorder ()
312
316
e .Post (w , req )
313
317
314
- Equals (t , http .StatusForbidden , w .Result ().StatusCode )
315
- body , _ := io .ReadAll (w .Result ().Body )
318
+ resp := w .Result ()
319
+ defer resp .Body .Close ()
320
+ Equals (t , http .StatusForbidden , resp .StatusCode )
321
+ body , _ := io .ReadAll (resp .Body )
316
322
exp := "Repo not allowlisted"
317
323
Assert (t , strings .Contains (string (body ), exp ), "exp %q to be contained in %q" , exp , string (body ))
318
324
expRepo , _ := models .NewRepo (models .Github , "baxterthehacker/public-repo" , "https://github.com/baxterthehacker/public-repo.git" , "" , "" )
@@ -345,8 +351,10 @@ func TestPost_GithubCommentNotAllowlistedWithSilenceErrors(t *testing.T) {
345
351
w := httptest .NewRecorder ()
346
352
e .Post (w , req )
347
353
348
- Equals (t , http .StatusForbidden , w .Result ().StatusCode )
349
- body , _ := io .ReadAll (w .Result ().Body )
354
+ resp := w .Result ()
355
+ defer resp .Body .Close ()
356
+ Equals (t , http .StatusForbidden , resp .StatusCode )
357
+ body , _ := io .ReadAll (resp .Body )
350
358
exp := "Repo not allowlisted"
351
359
Assert (t , strings .Contains (string (body ), exp ), "exp %q to be contained in %q" , exp , string (body ))
352
360
vcsClient .VerifyWasCalled (Never ()).CreateComment (Any [logging.SimpleLogging ](), Any [models.Repo ](), Any [int ](), Any [string ](), Any [string ]())
0 commit comments