(t *testing.T)
| 348 | } |
| 349 | |
| 350 | func TestRunItemEdit_DraftBodyOnly(t *testing.T) { |
| 351 | defer gock.Off() |
| 352 | |
| 353 | gock.New("https://api.github.com"). |
| 354 | Post("/graphql"). |
| 355 | BodyString(`{"query":"query DraftIssueByID.*","variables":{"id":"DI_item_id"}}`). |
| 356 | Reply(200). |
| 357 | JSON(map[string]any{ |
| 358 | "data": map[string]any{ |
| 359 | "node": map[string]any{ |
| 360 | "id": "DI_item_id", |
| 361 | "title": "existing title", |
| 362 | "body": "existing body", |
| 363 | }, |
| 364 | }, |
| 365 | }) |
| 366 | |
| 367 | gock.New("https://api.github.com"). |
| 368 | Post("/graphql"). |
| 369 | BodyString(`{"query":"mutation EditDraftIssueItem.*","variables":{"input":{"draftIssueId":"DI_item_id","title":"existing title","body":"new body"}}}`). |
| 370 | Reply(200). |
| 371 | JSON(map[string]any{ |
| 372 | "data": map[string]any{ |
| 373 | "updateProjectV2DraftIssue": map[string]any{ |
| 374 | "draftIssue": map[string]any{ |
| 375 | "title": "existing title", |
| 376 | "body": "new body", |
| 377 | }, |
| 378 | }, |
| 379 | }, |
| 380 | }) |
| 381 | |
| 382 | client := queries.NewTestClient() |
| 383 | |
| 384 | ios, _, stdout, _ := iostreams.Test() |
| 385 | ios.SetStdoutTTY(true) |
| 386 | |
| 387 | config := editItemConfig{ |
| 388 | io: ios, |
| 389 | opts: editItemOpts{ |
| 390 | titleChanged: false, |
| 391 | body: "new body", |
| 392 | bodyChanged: true, |
| 393 | itemID: "DI_item_id", |
| 394 | }, |
| 395 | client: client, |
| 396 | } |
| 397 | |
| 398 | err := runEditItem(config) |
| 399 | assert.NoError(t, err) |
| 400 | assert.Equal( |
| 401 | t, |
| 402 | "Edited draft issue \"existing title\"\n", |
| 403 | stdout.String()) |
| 404 | } |
| 405 | |
| 406 | func TestRunItemEdit_DraftFetchError(t *testing.T) { |
| 407 | defer gock.Off() |
nothing calls this directly
no test coverage detected