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

Function TestRunItemEdit_DraftTitleOnly

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

Source from the content-addressed store, hash-verified

292}
293
294func 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
350func TestRunItemEdit_DraftBodyOnly(t *testing.T) {
351 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