diff --git a/instrumentation/net/http/otelhttp/test/transport_test.go b/instrumentation/net/http/otelhttp/test/transport_test.go index 599eaf4f951..e61950dd7dd 100644 --- a/instrumentation/net/http/otelhttp/test/transport_test.go +++ b/instrumentation/net/http/otelhttp/test/transport_test.go @@ -101,13 +101,11 @@ func TestTransportErrorStatus(t *testing.T) { } resp, err := c.Do(r) if err == nil { - t.Fatal("transport should have returned an error, it didn't") - } - defer func() { if err := resp.Body.Close(); err != nil { t.Errorf("close response body: %v", err) } - }() + t.Fatal("transport should have returned an error, it didn't") + } // Check span. spans := spanRecorder.Ended()