@@ -200,7 +200,9 @@ func TestWithRequestDeadline(t *testing.T) {
200
200
t .Fatalf ("test setup failed, expected the new HTTP request context to have no deadline but got: %s" , remaning )
201
201
}
202
202
203
- w := httptest .NewRecorder ()
203
+ // TODO: remove WithFakeResponseController once
204
+ // https://github.com/golang/go/issues/60229 is fixed.
205
+ w := responsewritertesting .WithFakeResponseController (httptest .NewRecorder ())
204
206
withDeadline .ServeHTTP (w , testRequest )
205
207
206
208
if test .handlerCallCountExpected != callCount {
@@ -248,7 +250,9 @@ func TestWithRequestDeadlineWithClock(t *testing.T) {
248
250
// the request has arrived just now.
249
251
testRequest = testRequest .WithContext (request .WithReceivedTimestamp (testRequest .Context (), time .Now ()))
250
252
251
- w := httptest .NewRecorder ()
253
+ // TODO: remove WithFakeResponseController once
254
+ // https://github.com/golang/go/issues/60229 is fixed.
255
+ w := responsewritertesting .WithFakeResponseController (httptest .NewRecorder ())
252
256
withDeadline .ServeHTTP (w , testRequest )
253
257
254
258
if ! hasDeadlineGot {
@@ -274,7 +278,9 @@ func TestWithRequestDeadlineWithInvalidTimeoutIsAudited(t *testing.T) {
274
278
withDeadline = WithRequestInfo (withDeadline , & fakeRequestResolver {})
275
279
276
280
testRequest := newRequest (t , "/api/v1/namespaces?timeout=foo" )
277
- w := httptest .NewRecorder ()
281
+ // TODO: remove WithFakeResponseController once
282
+ // https://github.com/golang/go/issues/60229 is fixed.
283
+ w := responsewritertesting .WithFakeResponseController (httptest .NewRecorder ())
278
284
withDeadline .ServeHTTP (w , testRequest )
279
285
280
286
if handlerInvoked {
@@ -316,7 +322,9 @@ func TestWithRequestDeadlineWithPanic(t *testing.T) {
316
322
})
317
323
318
324
testRequest := newRequest (t , "/api/v1/namespaces?timeout=1s" )
319
- w := httptest .NewRecorder ()
325
+ // TODO: remove WithFakeResponseController once
326
+ // https://github.com/golang/go/issues/60229 is fixed.
327
+ w := responsewritertesting .WithFakeResponseController (httptest .NewRecorder ())
320
328
withPanicRecovery .ServeHTTP (w , testRequest )
321
329
322
330
if panicErrExpected != panicErrGot {
@@ -347,7 +355,9 @@ func TestWithRequestDeadlineWithRequestTimesOut(t *testing.T) {
347
355
withDeadline = WithRequestInfo (withDeadline , & fakeRequestResolver {})
348
356
349
357
testRequest := newRequest (t , fmt .Sprintf ("/api/v1/namespaces?timeout=%s" , timeout ))
350
- w := httptest .NewRecorder ()
358
+ // TODO: remove WithFakeResponseController once
359
+ // https://github.com/golang/go/issues/60229 is fixed.
360
+ w := responsewritertesting .WithFakeResponseController (httptest .NewRecorder ())
351
361
withDeadline .ServeHTTP (w , testRequest )
352
362
353
363
if errGot != context .DeadlineExceeded {
@@ -393,7 +403,9 @@ func TestWithFailedRequestAudit(t *testing.T) {
393
403
394
404
withAudit := withFailedRequestAudit (errorHandler , test .statusErr , fakeSink , fakeRuleEvaluator )
395
405
396
- w := httptest .NewRecorder ()
406
+ // TODO: remove WithFakeResponseController once
407
+ // https://github.com/golang/go/issues/60229 is fixed.
408
+ w := responsewritertesting .WithFakeResponseController (httptest .NewRecorder ())
397
409
testRequest := newRequest (t , "/apis/v1/namespaces/default/pods" )
398
410
info := request.RequestInfo {}
399
411
testRequest = testRequest .WithContext (request .WithRequestInfo (testRequest .Context (), & info ))
0 commit comments