MCPcopy
hub / github.com/cli/cli / RESTPayload

Function RESTPayload

pkg/httpmock/stub.go:201–215  ·  view source on GitHub ↗
(responseStatus int, responseBody string, cb func(payload map[string]interface{}))

Source from the content-addressed store, hash-verified

199}
200
201func RESTPayload(responseStatus int, responseBody string, cb func(payload map[string]interface{})) Responder {
202 return func(req *http.Request) (*http.Response, error) {
203 bodyData := make(map[string]interface{})
204 err := decodeJSONBody(req, &bodyData)
205 if err != nil {
206 return nil, err
207 }
208 cb(bodyData)
209
210 header := http.Header{
211 "Content-Type": []string{"application/json"},
212 }
213 return httpResponseWithHeader(responseStatus, req, bytes.NewBufferString(responseBody), header), nil
214 }
215}
216
217func GraphQLMutation(body string, cb func(map[string]interface{})) Responder {
218 return func(req *http.Request) (*http.Response, error) {

Callers 13

Test_createRunFunction · 0.92
TestCreateJobFunction · 0.92
Test_runAddFunction · 0.92
Test_createRunFunction · 0.92
Test_repoCreateFunction · 0.92
Test_addRunFunction · 0.92
Test_editRunFunction · 0.92
Test_editRun_interactiveFunction · 0.92
Test_runAddFunction · 0.92

Calls 2

decodeJSONBodyFunction · 0.85
httpResponseWithHeaderFunction · 0.85

Tested by 13

Test_createRunFunction · 0.74
TestCreateJobFunction · 0.74
Test_runAddFunction · 0.74
Test_createRunFunction · 0.74
Test_repoCreateFunction · 0.74
Test_addRunFunction · 0.74
Test_editRunFunction · 0.74
Test_editRun_interactiveFunction · 0.74
Test_runAddFunction · 0.74