summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Neil <dneil@google.com>2024-03-18 12:58:12 -0700
committerDamien Neil <dneil@google.com>2024-03-19 00:21:25 +0000
commit31d9683ed011ab20a0aa6ab62de563611851a2b8 (patch)
treeb3effa31bb3f4df83c2c0fcfe4e3a90cdd5e6734
parent12ddef72728707026a3d9adbbc28affa76faf688 (diff)
downloadgolang-x-net-31d9683ed011ab20a0aa6ab62de563611851a2b8.tar.gz
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 <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
-rw-r--r--http2/clientconn_test.go10
1 files changed, 4 insertions, 6 deletions
diff --git a/http2/clientconn_test.go b/http2/clientconn_test.go
index 6d94762..9a5b2b0 100644
--- a/http2/clientconn_test.go
+++ b/http2/clientconn_test.go
@@ -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 {
@@ -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)
@@ -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)
}