MCPcopy
hub / github.com/cli/cli / TestTitleSurvey

Function TestTitleSurvey

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

Source from the content-addressed store, hash-verified

221}
222
223func TestTitleSurvey(t *testing.T) {
224 tests := []struct {
225 name string
226 prompterMockInputs []string
227 expectedTitle string
228 expectStderr bool
229 }{
230 {
231 name: "title provided",
232 prompterMockInputs: []string{"title"},
233 expectedTitle: "title",
234 },
235 {
236 name: "first input empty",
237 prompterMockInputs: []string{"", "title"},
238 expectedTitle: "title",
239 expectStderr: true,
240 },
241 }
242 for _, tt := range tests {
243 t.Run(tt.name, func(t *testing.T) {
244 io, _, _, stderr := iostreams.Test()
245 pm := prompter.NewMockPrompter(t)
246 for _, input := range tt.prompterMockInputs {
247 pm.RegisterInput("Title (required)", func(string, string) (string, error) {
248 return input, nil
249 })
250 }
251
252 state := &IssueMetadataState{}
253 err := TitleSurvey(pm, io, state)
254
255 assert.NoError(t, err)
256 assert.Equal(t, tt.expectedTitle, state.Title)
257 if tt.expectStderr {
258 assert.Equal(t, "X Title cannot be blank\n", stderr.String())
259 }
260 })
261 }
262}
263
264func TestFieldsToEditSurvey_IssueOnlyFields(t *testing.T) {
265 t.Run("without Allowed flag omits Type", func(t *testing.T) {

Callers

nothing calls this directly

Calls 6

TestFunction · 0.92
NewMockPrompterFunction · 0.92
TitleSurveyFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected