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

Function TestRunItemEdit_JSON

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

Source from the content-addressed store, hash-verified

827}
828
829func TestRunItemEdit_JSON(t *testing.T) {
830 defer gock.Off()
831 // gock.Observe(gock.DumpRequest)
832
833 // edit item
834 gock.New("https://api.github.com").
835 Post("/graphql").
836 BodyString(`{"query":"mutation EditDraftIssueItem.*","variables":{"input":{"draftIssueId":"DI_item_id","title":"a title","body":"a new body"}}}`).
837 Reply(200).
838 JSON(map[string]any{
839 "data": map[string]any{
840 "updateProjectV2DraftIssue": map[string]any{
841 "draftIssue": map[string]any{
842 "id": "DI_item_id",
843 "title": "a title",
844 "body": "a new body",
845 },
846 },
847 },
848 })
849
850 client := queries.NewTestClient()
851
852 ios, _, stdout, _ := iostreams.Test()
853 config := editItemConfig{
854 io: ios,
855 opts: editItemOpts{
856 title: "a title",
857 titleChanged: true,
858 body: "a new body",
859 bodyChanged: true,
860 itemID: "DI_item_id",
861 exporter: cmdutil.NewJSONExporter(),
862 },
863 client: client,
864 }
865
866 err := runEditItem(config)
867 assert.NoError(t, err)
868 assert.JSONEq(
869 t,
870 `{"id":"DI_item_id","title":"a title","body":"a new body","type":"DraftIssue"}`,
871 stdout.String())
872}
873
874func TestRunItemEdit_ByName_SingleSelect(t *testing.T) {
875 defer gock.Off()

Callers

nothing calls this directly

Calls 6

NewTestClientFunction · 0.92
TestFunction · 0.92
NewJSONExporterFunction · 0.92
runEditItemFunction · 0.85
ReplyMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected