Skip to content

Commit

Permalink
http2: mark several testing functions as helpers
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
neild committed Mar 19, 2024
1 parent 12ddef7 commit 31d9683
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions http2/clientconn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func testClientConnReadFrame[T any](tc *testClientConn) T {
var v T
fr := tc.readFrame()
if fr == nil {
tc.t.Fatalf("got no frame, want frame %v", v)
tc.t.Fatalf("got no frame, want frame %T", v)
}
v, ok := fr.(T)
if !ok {
Expand All @@ -203,6 +203,7 @@ func testClientConnReadFrame[T any](tc *testClientConn) T {
// wantFrameType reads the next frame from the conn.
// It produces an error if the frame type is not the expected value.
func (tc *testClientConn) wantFrameType(want FrameType) {
tc.t.Helper()
fr := tc.readFrame()
if fr == nil {
tc.t.Fatalf("got no frame, want frame %v", want)
Expand All @@ -221,11 +222,8 @@ type wantHeader struct {
// wantHeaders reads a HEADERS frame and potential CONTINUATION frames,
// and asserts that they contain the expected headers.
func (tc *testClientConn) wantHeaders(want wantHeader) {
fr := tc.readFrame()
got, ok := fr.(*MetaHeadersFrame)
if !ok {
tc.t.Fatalf("got %v, want HEADERS frame", want)
}
tc.t.Helper()
got := testClientConnReadFrame[*MetaHeadersFrame](tc)
if got, want := got.StreamID, want.streamID; got != want {
tc.t.Fatalf("got stream ID %v, want %v", got, want)
}
Expand Down

0 comments on commit 31d9683

Please sign in to comment.