(t *testing.T)
| 373 | } |
| 374 | |
| 375 | func TestRunCreateItem_JSON(t *testing.T) { |
| 376 | defer gock.Off() |
| 377 | gock.Observe(gock.DumpRequest) |
| 378 | // get user ID |
| 379 | gock.New("https://api.github.com"). |
| 380 | Post("/graphql"). |
| 381 | MatchType("json"). |
| 382 | JSON(map[string]interface{}{ |
| 383 | "query": "query UserOrgOwner.*", |
| 384 | "variables": map[string]interface{}{ |
| 385 | "login": "monalisa", |
| 386 | }, |
| 387 | }). |
| 388 | Reply(200). |
| 389 | JSON(map[string]interface{}{ |
| 390 | "data": map[string]interface{}{ |
| 391 | "user": map[string]interface{}{ |
| 392 | "id": "an ID", |
| 393 | }, |
| 394 | }, |
| 395 | "errors": []interface{}{ |
| 396 | map[string]interface{}{ |
| 397 | "type": "NOT_FOUND", |
| 398 | "path": []string{"organization"}, |
| 399 | }, |
| 400 | }, |
| 401 | }) |
| 402 | |
| 403 | // get project ID |
| 404 | gock.New("https://api.github.com"). |
| 405 | Post("/graphql"). |
| 406 | MatchType("json"). |
| 407 | JSON(map[string]interface{}{ |
| 408 | "query": "query UserProject.*", |
| 409 | "variables": map[string]interface{}{ |
| 410 | "login": "monalisa", |
| 411 | "number": 1, |
| 412 | "firstItems": 0, |
| 413 | "afterItems": nil, |
| 414 | "firstFields": 0, |
| 415 | "afterFields": nil, |
| 416 | }, |
| 417 | }). |
| 418 | Reply(200). |
| 419 | JSON(map[string]interface{}{ |
| 420 | "data": map[string]interface{}{ |
| 421 | "user": map[string]interface{}{ |
| 422 | "projectV2": map[string]interface{}{ |
| 423 | "id": "an ID", |
| 424 | }, |
| 425 | }, |
| 426 | }, |
| 427 | }) |
| 428 | |
| 429 | // create item |
| 430 | gock.New("https://api.github.com"). |
| 431 | Post("/graphql"). |
| 432 | BodyString(`{"query":"mutation CreateDraftItem.*","variables":{"input":{"projectId":"an ID","title":"a title","body":""}}}`). |
nothing calls this directly
no test coverage detected