MCPcopy
hub / github.com/cli/cli / TestRunItemEdit_Number

Function TestRunItemEdit_Number

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

Source from the content-addressed store, hash-verified

426}
427
428func TestRunItemEdit_Number(t *testing.T) {
429 defer gock.Off()
430 // gock.Observe(gock.DumpRequest)
431
432 // edit item
433 gock.New("https://api.github.com").
434 Post("/graphql").
435 BodyString(`{"query":"mutation UpdateItemValues.*","variables":{"input":{"projectId":"project_id","itemId":"item_id","fieldId":"field_id","value":{"number":123.45}}}}`).
436 Reply(200).
437 JSON(map[string]interface{}{
438 "data": map[string]interface{}{
439 "updateProjectV2ItemFieldValue": map[string]interface{}{
440 "projectV2Item": map[string]interface{}{
441 "ID": "item_id",
442 "content": map[string]interface{}{
443 "__typename": "Issue",
444 "body": "body",
445 "title": "title",
446 "number": 1,
447 "repository": map[string]interface{}{
448 "nameWithOwner": "my-repo",
449 },
450 },
451 },
452 },
453 },
454 })
455
456 client := queries.NewTestClient()
457
458 ios, _, stdout, _ := iostreams.Test()
459 ios.SetStdoutTTY(true)
460
461 config := editItemConfig{
462 io: ios,
463 opts: editItemOpts{
464 number: 123.45,
465 numberChanged: true,
466 itemID: "item_id",
467 projectID: "project_id",
468 fieldID: "field_id",
469 },
470 client: client,
471 }
472
473 err := runEditItem(config)
474 assert.NoError(t, err)
475 assert.Equal(
476 t,
477 "Edited item \"title\"\n",
478 stdout.String())
479}
480
481func TestRunItemEdit_NumberZero(t *testing.T) {
482 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