MCPcopy Index your code
hub / github.com/go-dev-frame/sponge / TestPostStandard

Function TestPostStandard

pkg/httpcli/httpcli_test.go:143–168  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

141}
142
143func TestPostStandard(t *testing.T) {
144 requestAddr := runGoHTTPServer()
145
146 req := New()
147 req.SetURL(requestAddr + "/post")
148 req.SetHeaders(map[string]string{
149 "Authorization": "Bearer token",
150 })
151 req.SetBody(&myBody{
152 Name: "foo",
153 Email: "bar@gmail.com",
154 })
155
156 resp, err := req.POST()
157 if err != nil {
158 t.Fatal(err)
159 }
160
161 result := &StdResult{}
162 err = resp.BindJSON(result)
163 if err != nil {
164 t.Fatal(err)
165 }
166
167 t.Logf("%+v", result)
168}
169
170func TestPutStandard(t *testing.T) {
171 requestAddr := runGoHTTPServer()

Callers

nothing calls this directly

Calls 8

runGoHTTPServerFunction · 0.85
SetURLMethod · 0.80
SetHeadersMethod · 0.80
SetBodyMethod · 0.80
POSTMethod · 0.80
BindJSONMethod · 0.80
NewFunction · 0.70
FatalMethod · 0.45

Tested by

no test coverage detected