MCPcopy Index your code
hub / github.com/gavv/httpexpect / TestBinder_Basic

Function TestBinder_Basic

binder_test.go:55–93  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

53}
54
55func TestBinder_Basic(t *testing.T) {
56 handler := &mockHandler{
57 t: t,
58 http10: true,
59 chunked: false,
60 }
61
62 client := &http.Client{
63 Transport: NewBinder(handler),
64 }
65
66 req, err := http.NewRequest("GET", "http://example.com/path", strings.NewReader("body"))
67 if err != nil {
68 t.Fatal(err)
69 }
70
71 req.ProtoMajor = 1
72 req.ProtoMinor = 0
73 req.Proto = ""
74
75 resp, err := client.Do(req)
76 if err != nil {
77 t.Fatal(err)
78 }
79
80 header := http.Header{
81 "Content-Type": {"application/json"},
82 }
83
84 b, err := io.ReadAll(resp.Body)
85 if err != nil {
86 t.Fatal(err)
87 }
88
89 assert.Equal(t, header, resp.Header)
90 assert.Equal(t, `{"hello":"world"}`, string(b))
91
92 assert.Equal(t, []string(nil), resp.TransferEncoding)
93}
94
95func TestBinder_TLS(t *testing.T) {
96 handler := &mockHandler{t: t}

Callers

nothing calls this directly

Calls 4

DoMethod · 0.95
NewBinderFunction · 0.85
NewRequestMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…