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

Function TestRunItemEdit_DraftBodyOnly

pkg/cmd/project/item-edit/item_edit_test.go:350–404  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

348}
349
350func 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
406func TestRunItemEdit_DraftFetchError(t *testing.T) {
407 defer gock.Off()

Callers

nothing calls this directly

Calls 7

NewTestClientFunction · 0.92
TestFunction · 0.92
runEditItemFunction · 0.85
ReplyMethod · 0.80
SetStdoutTTYMethod · 0.80
EqualMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected