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

Function TestSetResultStateCheckFunc

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

Source from the content-addressed store, hash-verified

714}
715
716func TestSetResultStateCheckFunc(t *testing.T) {
717 c := tc().SetResultStateCheckFunc(func(resp *Response) ResultState {
718 if resp.StatusCode == http.StatusOK {
719 return SuccessState
720 } else {
721 return ErrorState
722 }
723 })
724 resp, err := c.R().Get("/status?code=200")
725 tests.AssertNoError(t, err)
726 tests.AssertEqual(t, SuccessState, resp.ResultState())
727
728 resp, err = c.R().Get("/status?code=201")
729 tests.AssertNoError(t, err)
730 tests.AssertEqual(t, ErrorState, resp.ResultState())
731
732 resp, err = c.R().Get("/status?code=399")
733 tests.AssertNoError(t, err)
734 tests.AssertEqual(t, ErrorState, resp.ResultState())
735
736 resp, err = c.R().Get("/status?code=404")
737 tests.AssertNoError(t, err)
738 tests.AssertEqual(t, ErrorState, resp.ResultState())
739}
740
741func TestCloneCookieJar(t *testing.T) {
742 c1 := C()

Callers

nothing calls this directly

Calls 7

AssertNoErrorFunction · 0.92
AssertEqualFunction · 0.92
tcFunction · 0.85
RMethod · 0.80
ResultStateMethod · 0.80
GetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…