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

Function TestRunAddItem_JSON

pkg/cmd/project/item-add/item_add_test.go:448–562  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

446}
447
448func TestRunAddItem_JSON(t *testing.T) {
449 defer gock.Off()
450 gock.Observe(gock.DumpRequest)
451
452 // get user ID
453 gock.New("https://api.github.com").
454 Post("/graphql").
455 MatchType("json").
456 JSON(map[string]any{
457 "query": "query UserOrgOwner.*",
458 "variables": map[string]any{
459 "login": "monalisa",
460 },
461 }).
462 Reply(200).
463 JSON(map[string]any{
464 "data": map[string]any{
465 "user": map[string]any{
466 "id": "an ID",
467 },
468 },
469 "errors": []any{
470 map[string]any{
471 "type": "NOT_FOUND",
472 "path": []string{"organization"},
473 },
474 },
475 })
476
477 // get project ID
478 gock.New("https://api.github.com").
479 Post("/graphql").
480 MatchType("json").
481 JSON(map[string]any{
482 "query": "query UserProject.*",
483 "variables": map[string]any{
484 "login": "monalisa",
485 "number": 1,
486 "firstItems": 0,
487 "afterItems": nil,
488 "firstFields": 0,
489 "afterFields": nil,
490 },
491 }).
492 Reply(200).
493 JSON(map[string]any{
494 "data": map[string]any{
495 "user": map[string]any{
496 "projectV2": map[string]any{
497 "id": "an ID",
498 },
499 },
500 },
501 })
502
503 // get item ID
504 gock.New("https://api.github.com").
505 Post("/graphql").

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected