MCPcopy Create free account
hub / github.com/imroc/req / TestFramerWriteReadGoAway

Function TestFramerWriteReadGoAway

internal/http2/frame_test.go:156–179  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

154}
155
156func TestFramerWriteReadGoAway(t *testing.T) {
157 var buf bytes.Buffer
158 fw := NewFramer(&buf, nil)
159 fw.WriteGoAway(0, ErrCodeNo, []byte("shutdown"))
160
161 fr := NewFramer(nil, &buf)
162 f, err := fr.ReadFrame()
163 if err != nil {
164 t.Fatalf("ReadFrame failed: %v", err)
165 }
166 gf, ok := f.(*GoAwayFrame)
167 if !ok {
168 t.Fatalf("expected *GoAwayFrame, got %T", f)
169 }
170 if gf.LastStreamID != 0 {
171 t.Fatalf("LastStreamID = %d, want 0", gf.LastStreamID)
172 }
173 if gf.ErrCode != ErrCodeNo {
174 t.Fatalf("ErrCode = %d, want %d", gf.ErrCode, ErrCodeNo)
175 }
176 if string(gf.DebugData()) != "shutdown" {
177 t.Fatalf("DebugData = %q, want 'shutdown'", string(gf.DebugData()))
178 }
179}
180
181func TestErrCodeString(t *testing.T) {
182 tests := []struct {

Callers

nothing calls this directly

Calls 4

WriteGoAwayMethod · 0.95
ReadFrameMethod · 0.95
NewFramerFunction · 0.85
DebugDataMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…