MCPcopy Create free account
hub / github.com/cli/cli / TestRESTAndRESTWithNextErrorTypeParity

Function TestRESTAndRESTWithNextErrorTypeParity

api/client_test.go:169–191  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

167}
168
169func TestRESTAndRESTWithNextErrorTypeParity(t *testing.T) {
170 reg := &httpmock.Registry{}
171 defer reg.Verify(t)
172 client := newTestClient(reg)
173
174 responder := func(req *http.Request) (*http.Response, error) {
175 return &http.Response{
176 Request: req,
177 StatusCode: http.StatusNotFound,
178 Body: io.NopCloser(bytes.NewBufferString(`{"message": "Not Found"}`)),
179 Header: http.Header{"Content-Type": {"application/json"}},
180 }, nil
181 }
182 reg.Register(httpmock.MatchAny, responder)
183 reg.Register(httpmock.MatchAny, responder)
184
185 restErr := client.REST("github.com", http.MethodGet, "repos/owner/repo/items", nil, nil)
186 _, restWithNextErr := client.RESTWithNext("github.com", http.MethodGet, "repos/owner/repo/items", nil, nil)
187
188 require.Error(t, restErr)
189 require.Error(t, restWithNextErr)
190 assert.IsType(t, restErr, restWithNextErr)
191}
192
193func TestRESTWithNext(t *testing.T) {
194 reg := &httpmock.Registry{}

Callers

nothing calls this directly

Calls 6

VerifyMethod · 0.95
RegisterMethod · 0.95
newTestClientFunction · 0.85
RESTMethod · 0.65
RESTWithNextMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected