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

Function TestRunCreate_JSON

pkg/cmd/project/create/create_test.go:279–348  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

277}
278
279func TestRunCreate_JSON(t *testing.T) {
280 defer gock.Off()
281 gock.Observe(gock.DumpRequest)
282
283 // get user ID
284 gock.New("https://api.github.com").
285 Post("/graphql").
286 MatchType("json").
287 JSON(map[string]interface{}{
288 "query": "query UserOrgOwner.*",
289 "variables": map[string]string{
290 "login": "monalisa",
291 },
292 }).
293 Reply(200).
294 JSON(map[string]interface{}{
295 "data": map[string]interface{}{
296 "user": map[string]interface{}{
297 "id": "an ID",
298 "login": "monalisa",
299 },
300 },
301 "errors": []interface{}{
302 map[string]interface{}{
303 "type": "NOT_FOUND",
304 "path": []string{"organization"},
305 },
306 },
307 })
308
309 // create project
310 gock.New("https://api.github.com").
311 Post("/graphql").
312 BodyString(`{"query":"mutation CreateProjectV2.*"variables":{"afterFields":null,"afterItems":null,"firstFields":0,"firstItems":0,"input":{"ownerId":"an ID","title":"a title"}}}`).
313 Reply(200).
314 JSON(map[string]interface{}{
315 "data": map[string]interface{}{
316 "createProjectV2": map[string]interface{}{
317 "projectV2": map[string]interface{}{
318 "number": 1,
319 "title": "a title",
320 "url": "http://a-url.com",
321 "owner": map[string]string{
322 "login": "monalisa",
323 },
324 },
325 },
326 },
327 })
328
329 client := queries.NewTestClient()
330
331 ios, _, stdout, _ := iostreams.Test()
332 config := createConfig{
333 opts: createOpts{
334 title: "a title",
335 owner: "monalisa",
336 exporter: cmdutil.NewJSONExporter(),

Callers

nothing calls this directly

Calls 6

NewTestClientFunction · 0.92
TestFunction · 0.92
NewJSONExporterFunction · 0.92
runCreateFunction · 0.85
ReplyMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected