Skip to content

Commit 5c452ef

Browse files
committed
fix: pr comments
1 parent b4e165f commit 5c452ef

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

http_dumper_test.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ package godump
33
import (
44
"bytes"
55
"errors"
6-
"github.com/stretchr/testify/assert"
7-
"github.com/stretchr/testify/require"
86
"io"
97
"net/http"
108
"net/http/httptest"
119
"net/url"
1210
"testing"
11+
12+
"github.com/stretchr/testify/require"
1313
)
1414

1515
func newDebugClient(t *testing.T, debug bool, transport http.RoundTripper) (*http.Client, *bytes.Buffer) {
@@ -57,7 +57,7 @@ func TestHTTPDebugTransport_WithDebugEnabled(t *testing.T) {
5757
w.Header().Set("X-Test-Header", "TestValue")
5858
w.WriteHeader(http.StatusOK)
5959
_, err := w.Write([]byte(`{"success":true}`))
60-
assert.NoError(t, err, "failed to write response")
60+
require.NoError(t, err, "failed to write response")
6161
})
6262

6363
req := mustNewRequest(t, http.MethodGet, server.URL, http.NoBody)
@@ -66,10 +66,10 @@ func TestHTTPDebugTransport_WithDebugEnabled(t *testing.T) {
6666
output := stripANSI(buf.String())
6767
t.Logf("Captured dump:\n%s", output)
6868

69-
assert.Contains(t, output, "Transaction =>")
70-
assert.Contains(t, output, "Request =>")
71-
assert.Contains(t, output, "Response =>")
72-
assert.Contains(t, output, `"success":true`)
69+
require.Contains(t, output, "Transaction =>")
70+
require.Contains(t, output, "Request =>")
71+
require.Contains(t, output, "Response =>")
72+
require.Contains(t, output, `"success":true`)
7373
}
7474

7575
func TestHTTPDebugTransport_WithDebugDisabled(t *testing.T) {
@@ -94,7 +94,7 @@ func TestHTTPDebugTransport_WithDebugDisabled(t *testing.T) {
9494
output := stripANSI(buf.String())
9595
t.Logf("Captured dump:\n%s", output)
9696

97-
assert.NotContains(t, output, "Transaction =>", "did not expect 'Transaction =>' in dump when debug disabled")
97+
require.NotContains(t, output, "Transaction =>", "did not expect 'Transaction =>' in dump when debug disabled")
9898
}
9999

100100
func TestHTTPDebugTransport_RoundTripError(t *testing.T) {
@@ -110,15 +110,15 @@ func TestHTTPDebugTransport_RoundTripError(t *testing.T) {
110110

111111
// Expect simulated network error
112112
require.Error(t, err)
113-
assert.Contains(t, err.Error(), "simulated network error")
113+
require.Contains(t, err.Error(), "simulated network error")
114114

115115
// Ensure no response body to close
116116
require.Nil(t, resp)
117117

118118
output := stripANSI(buf.String())
119119
t.Logf("Captured dump (error case):\n%s", output)
120120

121-
assert.NotContains(t, output, "Transaction =>", "did not expect Transaction block when RoundTrip failed")
121+
require.NotContains(t, output, "Transaction =>", "did not expect Transaction block when RoundTrip failed")
122122
}
123123

124124
func TestHTTPDebugTransport_SetDebugToggle(t *testing.T) {
@@ -133,7 +133,7 @@ func TestHTTPDebugTransport_SetDebugToggle(t *testing.T) {
133133
mustDoRequest(t, client, mustNewRequest(t, http.MethodGet, server.URL, http.NoBody))
134134
output := stripANSI(buf.String())
135135
t.Logf("Dump with debug disabled:\n%s", output)
136-
assert.NotContains(t, output, "Transaction =>", "should not log when debug disabled")
136+
require.NotContains(t, output, "Transaction =>", "should not log when debug disabled")
137137

138138
// Enable debug
139139
tr, ok := client.Transport.(*HTTPDebugTransport)
@@ -144,7 +144,7 @@ func TestHTTPDebugTransport_SetDebugToggle(t *testing.T) {
144144
mustDoRequest(t, client, mustNewRequest(t, http.MethodGet, server.URL, http.NoBody))
145145
output = stripANSI(buf.String())
146146
t.Logf("Dump with debug enabled:\n%s", output)
147-
assert.Contains(t, output, "Transaction =>", "should log when debug enabled")
147+
require.Contains(t, output, "Transaction =>", "should log when debug enabled")
148148
}
149149

150150
// roundTripFunc lets us use a function as a RoundTripper in tests.
@@ -169,7 +169,7 @@ func TestHTTPDebugTransport_PassThroughRoundTripError(t *testing.T) {
169169

170170
// Assert error behavior
171171
require.Error(t, err)
172-
assert.Contains(t, err.Error(), "HTTPDebugTransport: pass-through round trip failed")
172+
require.Contains(t, err.Error(), "HTTPDebugTransport: pass-through round trip failed")
173173
require.ErrorIs(t, err, ErrSimulatedTransportFailure)
174174

175175
// Response should be nil
@@ -196,7 +196,7 @@ func TestHTTPDebugTransport_RequestDumpFailure(t *testing.T) {
196196

197197
// Assert error behavior
198198
require.Error(t, err)
199-
assert.Contains(t, err.Error(), "HTTPDebugTransport: failed to dump request")
199+
require.Contains(t, err.Error(), "HTTPDebugTransport: failed to dump request")
200200
}
201201

202202
type errorBody struct{}
@@ -223,7 +223,7 @@ func TestHTTPDebugTransport_ResponseDumpFailure(t *testing.T) {
223223

224224
// Assert response dump failure
225225
require.Error(t, err)
226-
assert.Contains(t, err.Error(), "HTTPDebugTransport: failed to dump response")
226+
require.Contains(t, err.Error(), "HTTPDebugTransport: failed to dump response")
227227
require.ErrorIs(t, err, errSimulatedBodyReadFailure)
228228

229229
// Response should be nil because dump failed

0 commit comments

Comments
 (0)