MCPcopy Index your code
hub / github.com/cli/cli / TestMetadataSurvey_keepExisting

Function TestMetadataSurvey_keepExisting

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

Source from the content-addressed store, hash-verified

85}
86
87func TestMetadataSurvey_keepExisting(t *testing.T) {
88 ios, _, stdout, stderr := iostreams.Test()
89
90 repo := ghrepo.New("OWNER", "REPO")
91
92 fetcher := &metadataFetcher{
93 metadataResult: &api.RepoMetadataResult{
94 Labels: []api.RepoLabel{
95 {Name: "help wanted"},
96 {Name: "good first issue"},
97 },
98 Projects: []api.RepoProject{
99 {Name: "Huge Refactoring"},
100 {Name: "The road to 1.0"},
101 },
102 },
103 }
104
105 pm := prompter.NewMockPrompter(t)
106 pm.RegisterMultiSelect("What would you like to add?", []string{}, []string{"Assignees", "Labels", "Projects", "Milestone"}, func(_ string, _, _ []string) ([]int, error) {
107 return []int{1, 2}, nil
108 })
109 pm.RegisterMultiSelect("Labels", []string{}, []string{"help wanted", "good first issue"}, func(_ string, _, _ []string) ([]int, error) {
110 return []int{1}, nil
111 })
112 pm.RegisterMultiSelect("Projects", []string{}, []string{"Huge Refactoring", "The road to 1.0"}, func(_ string, _, _ []string) ([]int, error) {
113 return []int{1}, nil
114 })
115
116 state := &IssueMetadataState{
117 Assignees: []string{"hubot"},
118 }
119
120 err := MetadataSurvey(pm, ios, repo, fetcher, state, gh.ProjectsV1Supported, nil, nil)
121 assert.NoError(t, err)
122
123 assert.Equal(t, "", stdout.String())
124 assert.Equal(t, "", stderr.String())
125
126 assert.Equal(t, []string{"hubot"}, state.Assignees)
127 assert.Equal(t, []string{"good first issue"}, state.Labels)
128 assert.Equal(t, []string{"The road to 1.0"}, state.ProjectTitles)
129}
130
131// TODO projectsV1Deprecation
132// Remove this test and projectsV1MetadataFetcherSpy

Callers

nothing calls this directly

Calls 6

TestFunction · 0.92
NewFunction · 0.92
NewMockPrompterFunction · 0.92
MetadataSurveyFunction · 0.85
EqualMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected