Skip to content

Commit 31d9683

Browse files
committed
http2: mark several testing functions as helpers
Change-Id: Ib5519fd882b3692efadd6191fbebbf042c9aa77d Reviewed-on: https://go-review.googlesource.com/c/net/+/572376 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Jonathan Amsterdam <[email protected]>
1 parent 12ddef7 commit 31d9683

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

http2/clientconn_test.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ func testClientConnReadFrame[T any](tc *testClientConn) T {
191191
var v T
192192
fr := tc.readFrame()
193193
if fr == nil {
194-
tc.t.Fatalf("got no frame, want frame %v", v)
194+
tc.t.Fatalf("got no frame, want frame %T", v)
195195
}
196196
v, ok := fr.(T)
197197
if !ok {
@@ -203,6 +203,7 @@ func testClientConnReadFrame[T any](tc *testClientConn) T {
203203
// wantFrameType reads the next frame from the conn.
204204
// It produces an error if the frame type is not the expected value.
205205
func (tc *testClientConn) wantFrameType(want FrameType) {
206+
tc.t.Helper()
206207
fr := tc.readFrame()
207208
if fr == nil {
208209
tc.t.Fatalf("got no frame, want frame %v", want)
@@ -221,11 +222,8 @@ type wantHeader struct {
221222
// wantHeaders reads a HEADERS frame and potential CONTINUATION frames,
222223
// and asserts that they contain the expected headers.
223224
func (tc *testClientConn) wantHeaders(want wantHeader) {
224-
fr := tc.readFrame()
225-
got, ok := fr.(*MetaHeadersFrame)
226-
if !ok {
227-
tc.t.Fatalf("got %v, want HEADERS frame", want)
228-
}
225+
tc.t.Helper()
226+
got := testClientConnReadFrame[*MetaHeadersFrame](tc)
229227
if got, want := got.StreamID, want.streamID; got != want {
230228
tc.t.Fatalf("got stream ID %v, want %v", got, want)
231229
}

0 commit comments

Comments
 (0)