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

Function TestFieldsToEditSurvey_IssueOnlyFields

pkg/cmd/pr/shared/survey_test.go:264–295  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

262}
263
264func TestFieldsToEditSurvey_IssueOnlyFields(t *testing.T) {
265 t.Run("without Allowed flag omits Type", func(t *testing.T) {
266 pm := prompter.NewMockPrompter(t)
267 pm.RegisterMultiSelect("What would you like to edit?", []string{},
268 // Type should NOT appear here
269 []string{"Title", "Body", "Assignees", "Labels", "Projects", "Milestone"},
270 func(_ string, _, _ []string) ([]int, error) {
271 return []int{0}, nil
272 })
273
274 editable := &Editable{}
275 err := FieldsToEditSurvey(pm, editable)
276 require.NoError(t, err)
277 assert.True(t, editable.Title.Edited)
278 })
279
280 t.Run("with Allowed flag includes Type", func(t *testing.T) {
281 pm := prompter.NewMockPrompter(t)
282 pm.RegisterMultiSelect("What would you like to edit?", []string{},
283 // Type should appear between Labels and Projects
284 []string{"Title", "Body", "Assignees", "Labels", "Type", "Projects", "Milestone"},
285 func(_ string, _, _ []string) ([]int, error) {
286 return []int{4}, nil // select Type
287 })
288
289 editable := &Editable{}
290 editable.IssueType.Selectable = true
291 err := FieldsToEditSurvey(pm, editable)
292 require.NoError(t, err)
293 assert.True(t, editable.IssueType.Edited)
294 })
295}

Callers

nothing calls this directly

Calls 3

NewMockPrompterFunction · 0.92
FieldsToEditSurveyFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected