MCPcopy
hub / github.com/cli/cli / TestMetadataSurvey_selectAll

Function TestMetadataSurvey_selectAll

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

Source from the content-addressed store, hash-verified

22}
23
24func TestMetadataSurvey_selectAll(t *testing.T) {
25 ios, _, stdout, stderr := iostreams.Test()
26
27 repo := ghrepo.New("OWNER", "REPO")
28
29 fetcher := &metadataFetcher{
30 metadataResult: &api.RepoMetadataResult{
31 AssignableUsers: []api.AssignableUser{
32 api.NewAssignableUser("", "hubot", ""),
33 api.NewAssignableUser("", "monalisa", ""),
34 },
35 Labels: []api.RepoLabel{
36 {Name: "help wanted"},
37 {Name: "good first issue"},
38 },
39 Projects: []api.RepoProject{
40 {Name: "Huge Refactoring"},
41 {Name: "The road to 1.0"},
42 },
43 Milestones: []api.RepoMilestone{
44 {Title: "1.2 patch release"},
45 },
46 },
47 }
48
49 pm := prompter.NewMockPrompter(t)
50 pm.RegisterMultiSelect("What would you like to add?",
51 []string{}, []string{"Reviewers", "Assignees", "Labels", "Projects", "Milestone"}, func(_ string, _, _ []string) ([]int, error) {
52 return []int{0, 1, 2, 3, 4}, nil
53 })
54 pm.RegisterMultiSelect("Reviewers", []string{}, []string{"hubot", "monalisa"}, func(_ string, _, _ []string) ([]int, error) {
55 return []int{1}, nil
56 })
57 pm.RegisterMultiSelect("Assignees", []string{}, []string{"hubot", "monalisa"}, func(_ string, _, _ []string) ([]int, error) {
58 return []int{0}, nil
59 })
60 pm.RegisterMultiSelect("Labels", []string{}, []string{"help wanted", "good first issue"}, func(_ string, _, _ []string) ([]int, error) {
61 return []int{1}, nil
62 })
63 pm.RegisterMultiSelect("Projects", []string{}, []string{"Huge Refactoring", "The road to 1.0"}, func(_ string, _, _ []string) ([]int, error) {
64 return []int{1}, nil
65 })
66 pm.RegisterSelect("Milestone", []string{"(none)", "1.2 patch release"}, func(_, _ string, _ []string) (int, error) {
67 return 0, nil
68 })
69
70 state := &IssueMetadataState{
71 Assignees: []string{"hubot"},
72 Type: PRMetadata,
73 }
74 err := MetadataSurvey(pm, ios, repo, fetcher, state, gh.ProjectsV1Supported, nil, nil)
75 assert.NoError(t, err)
76
77 assert.Equal(t, "", stdout.String())
78 assert.Equal(t, "", stderr.String())
79
80 assert.Equal(t, []string{"hubot"}, state.Assignees)
81 assert.Equal(t, []string{"monalisa"}, state.Reviewers)

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected