MCPcopy
hub / github.com/cli/cli / TestRunItemEdit_DraftBodyOnly

Function TestRunItemEdit_DraftBodyOnly

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

Source from the content-addressed store, hash-verified

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

Tested by

no test coverage detected