MCPcopy
hub / github.com/cli/cli / TestRunItemEdit_DraftTitleOnly

Function TestRunItemEdit_DraftTitleOnly

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

Source from the content-addressed store, hash-verified

232}
233
234func TestRunItemEdit_DraftTitleOnly(t *testing.T) {
235 defer gock.Off()
236
237 gock.New("https://api.github.com").
238 Post("/graphql").
239 BodyString(`{"query":"query DraftIssueByID.*","variables":{"id":"DI_item_id"}}`).
240 Reply(200).
241 JSON(map[string]interface{}{
242 "data": map[string]interface{}{
243 "node": map[string]interface{}{
244 "id": "DI_item_id",
245 "title": "existing title",
246 "body": "existing body",
247 },
248 },
249 })
250
251 gock.New("https://api.github.com").
252 Post("/graphql").
253 BodyString(`{"query":"mutation EditDraftIssueItem.*","variables":{"input":{"draftIssueId":"DI_item_id","title":"new title","body":"existing body"}}}`).
254 Reply(200).
255 JSON(map[string]interface{}{
256 "data": map[string]interface{}{
257 "updateProjectV2DraftIssue": map[string]interface{}{
258 "draftIssue": map[string]interface{}{
259 "title": "new title",
260 "body": "existing body",
261 },
262 },
263 },
264 })
265
266 client := queries.NewTestClient()
267
268 ios, _, stdout, _ := iostreams.Test()
269 ios.SetStdoutTTY(true)
270
271 config := editItemConfig{
272 io: ios,
273 opts: editItemOpts{
274 title: "new title",
275 titleChanged: true,
276 bodyChanged: false,
277 itemID: "DI_item_id",
278 },
279 client: client,
280 }
281
282 err := runEditItem(config)
283 assert.NoError(t, err)
284 assert.Equal(
285 t,
286 "Edited draft issue \"new title\"\n",
287 stdout.String())
288}
289
290func TestRunItemEdit_DraftBodyOnly(t *testing.T) {
291 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