MCPcopy Index your code
hub / github.com/imroc/req / TestAutoDecode

Function TestAutoDecode

client_test.go:230–255  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

228}
229
230func TestAutoDecode(t *testing.T) {
231 c := tc().DisableAutoDecode()
232 resp, err := c.R().Get("/gbk")
233 assertSuccess(t, resp, err)
234 tests.AssertEqual(t, toGbk("我是roc"), resp.Bytes())
235
236 resp, err = c.EnableAutoDecode().R().Get("/gbk")
237 assertSuccess(t, resp, err)
238 tests.AssertEqual(t, "我是roc", resp.String())
239
240 resp, err = c.SetAutoDecodeContentType("html").R().Get("/gbk")
241 assertSuccess(t, resp, err)
242 tests.AssertEqual(t, toGbk("我是roc"), resp.Bytes())
243 resp, err = c.SetAutoDecodeContentType("text").R().Get("/gbk")
244 assertSuccess(t, resp, err)
245 tests.AssertEqual(t, "我是roc", resp.String())
246 resp, err = c.SetAutoDecodeContentTypeFunc(func(contentType string) bool {
247 return strings.Contains(contentType, "text")
248 }).R().Get("/gbk")
249 assertSuccess(t, resp, err)
250 tests.AssertEqual(t, "我是roc", resp.String())
251
252 resp, err = c.SetAutoDecodeAllContentType().R().Get("/gbk-no-charset")
253 assertSuccess(t, resp, err)
254 tests.AssertContains(t, resp.String(), "我是roc", true)
255}
256
257func TestSetTimeout(t *testing.T) {
258 timeout := 100 * time.Second

Callers

nothing calls this directly

Calls 14

AssertEqualFunction · 0.92
AssertContainsFunction · 0.92
tcFunction · 0.85
assertSuccessFunction · 0.85
toGbkFunction · 0.85
RMethod · 0.80
BytesMethod · 0.80
DisableAutoDecodeMethod · 0.45
GetMethod · 0.45
EnableAutoDecodeMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…