(t *testing.T)
| 292 | } |
| 293 | |
| 294 | func TestRunItemEdit_DraftTitleOnly(t *testing.T) { |
| 295 | defer gock.Off() |
| 296 | |
| 297 | gock.New("https://api.github.com"). |
| 298 | Post("/graphql"). |
| 299 | BodyString(`{"query":"query DraftIssueByID.*","variables":{"id":"DI_item_id"}}`). |
| 300 | Reply(200). |
| 301 | JSON(map[string]any{ |
| 302 | "data": map[string]any{ |
| 303 | "node": map[string]any{ |
| 304 | "id": "DI_item_id", |
| 305 | "title": "existing title", |
| 306 | "body": "existing body", |
| 307 | }, |
| 308 | }, |
| 309 | }) |
| 310 | |
| 311 | gock.New("https://api.github.com"). |
| 312 | Post("/graphql"). |
| 313 | BodyString(`{"query":"mutation EditDraftIssueItem.*","variables":{"input":{"draftIssueId":"DI_item_id","title":"new title","body":"existing body"}}}`). |
| 314 | Reply(200). |
| 315 | JSON(map[string]any{ |
| 316 | "data": map[string]any{ |
| 317 | "updateProjectV2DraftIssue": map[string]any{ |
| 318 | "draftIssue": map[string]any{ |
| 319 | "title": "new title", |
| 320 | "body": "existing body", |
| 321 | }, |
| 322 | }, |
| 323 | }, |
| 324 | }) |
| 325 | |
| 326 | client := queries.NewTestClient() |
| 327 | |
| 328 | ios, _, stdout, _ := iostreams.Test() |
| 329 | ios.SetStdoutTTY(true) |
| 330 | |
| 331 | config := editItemConfig{ |
| 332 | io: ios, |
| 333 | opts: editItemOpts{ |
| 334 | title: "new title", |
| 335 | titleChanged: true, |
| 336 | bodyChanged: false, |
| 337 | itemID: "DI_item_id", |
| 338 | }, |
| 339 | client: client, |
| 340 | } |
| 341 | |
| 342 | err := runEditItem(config) |
| 343 | assert.NoError(t, err) |
| 344 | assert.Equal( |
| 345 | t, |
| 346 | "Edited draft issue \"new title\"\n", |
| 347 | stdout.String()) |
| 348 | } |
| 349 | |
| 350 | func TestRunItemEdit_DraftBodyOnly(t *testing.T) { |
| 351 | defer gock.Off() |
nothing calls this directly
no test coverage detected