MCPcopy
hub / github.com/valyala/fasthttp / testClientPost

Function testClientPost

client_test.go:3200–3221  ·  view source on GitHub ↗
(t *testing.T, c clientPoster, addr string, n int)

Source from the content-addressed store, hash-verified

3198}
3199
3200func testClientPost(t *testing.T, c clientPoster, addr string, n int) {
3201 var buf []byte
3202 var args Args
3203 for i := range n {
3204 uri := fmt.Sprintf("%s/foo/%d?bar=baz", addr, i)
3205 args.Set("xx", fmt.Sprintf("yy%d", i))
3206 args.Set("zzz", fmt.Sprintf("qwe_%d", i))
3207 argsS := args.String()
3208 statusCode, body, err := c.Post(buf, uri, &args)
3209 buf = body
3210 if err != nil {
3211 t.Errorf("unexpected error when doing http request: %v", err)
3212 }
3213 if statusCode != StatusOK {
3214 t.Errorf("unexpected status code: %d. Expecting %d", statusCode, StatusOK)
3215 }
3216 s := string(body)
3217 if s != argsS {
3218 t.Errorf("unexpected response %q. Expecting %q", s, argsS)
3219 }
3220 }
3221}
3222
3223func testHostClientGet(t *testing.T, c *HostClient, n int) {
3224 testClientGet(t, c, "http://google.com", n)

Callers 6

TestClientManyServersFunction · 0.85
TestClientPostFunction · 0.85
TestClientConcurrentFunction · 0.85
testHostClientPostFunction · 0.85
TestClientTransportExFunction · 0.85

Calls 3

SetMethod · 0.95
StringMethod · 0.95
PostMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…