MCPcopy
hub / github.com/cli/cli / TestRunItemEdit_Draft

Function TestRunItemEdit_Draft

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

Source from the content-addressed store, hash-verified

187}
188
189func TestRunItemEdit_Draft(t *testing.T) {
190 defer gock.Off()
191 // gock.Observe(gock.DumpRequest)
192
193 // edit item
194 gock.New("https://api.github.com").
195 Post("/graphql").
196 BodyString(`{"query":"mutation EditDraftIssueItem.*","variables":{"input":{"draftIssueId":"DI_item_id","title":"a title","body":"a new body"}}}`).
197 Reply(200).
198 JSON(map[string]interface{}{
199 "data": map[string]interface{}{
200 "updateProjectV2DraftIssue": map[string]interface{}{
201 "draftIssue": map[string]interface{}{
202 "title": "a title",
203 "body": "a new body",
204 },
205 },
206 },
207 })
208
209 client := queries.NewTestClient()
210
211 ios, _, stdout, _ := iostreams.Test()
212 ios.SetStdoutTTY(true)
213
214 config := editItemConfig{
215 io: ios,
216 opts: editItemOpts{
217 title: "a title",
218 titleChanged: true,
219 body: "a new body",
220 bodyChanged: true,
221 itemID: "DI_item_id",
222 },
223 client: client,
224 }
225
226 err := runEditItem(config)
227 assert.NoError(t, err)
228 assert.Equal(
229 t,
230 "Edited draft issue \"a title\"\n",
231 stdout.String())
232}
233
234func TestRunItemEdit_DraftTitleOnly(t *testing.T) {
235 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