TODO projectsV1Deprecation Remove this test and projectsV1MetadataFetcherSpy
(t *testing.T)
| 131 | // TODO projectsV1Deprecation |
| 132 | // Remove this test and projectsV1MetadataFetcherSpy |
| 133 | func TestMetadataSurveyProjectV1Deprecation(t *testing.T) { |
| 134 | t.Run("when projectsV1 is supported, requests projectsV1", func(t *testing.T) { |
| 135 | ios, _, _, _ := iostreams.Test() |
| 136 | repo := ghrepo.New("OWNER", "REPO") |
| 137 | |
| 138 | fetcher := &projectsV1MetadataFetcherSpy{} |
| 139 | pm := prompter.NewMockPrompter(t) |
| 140 | pm.RegisterMultiSelect("What would you like to add?", []string{}, []string{"Assignees", "Labels", "Projects", "Milestone"}, func(_ string, _, options []string) ([]int, error) { |
| 141 | i, err := prompter.IndexFor(options, "Projects") |
| 142 | require.NoError(t, err) |
| 143 | return []int{i}, nil |
| 144 | }) |
| 145 | pm.RegisterMultiSelect("Projects", []string{}, []string{"Huge Refactoring"}, func(_ string, _, _ []string) ([]int, error) { |
| 146 | return []int{0}, nil |
| 147 | }) |
| 148 | |
| 149 | err := MetadataSurvey(pm, ios, repo, fetcher, &IssueMetadataState{}, gh.ProjectsV1Supported, nil, nil) |
| 150 | require.ErrorContains(t, err, "expected test error") |
| 151 | |
| 152 | require.True(t, fetcher.projectsV1Requested, "expected projectsV1 to be requested") |
| 153 | }) |
| 154 | |
| 155 | t.Run("when projectsV1 is supported, does not request projectsV1", func(t *testing.T) { |
| 156 | ios, _, _, _ := iostreams.Test() |
| 157 | repo := ghrepo.New("OWNER", "REPO") |
| 158 | |
| 159 | fetcher := &projectsV1MetadataFetcherSpy{} |
| 160 | pm := prompter.NewMockPrompter(t) |
| 161 | pm.RegisterMultiSelect("What would you like to add?", []string{}, []string{"Assignees", "Labels", "Projects", "Milestone"}, func(_ string, _, options []string) ([]int, error) { |
| 162 | i, err := prompter.IndexFor(options, "Projects") |
| 163 | require.NoError(t, err) |
| 164 | return []int{i}, nil |
| 165 | }) |
| 166 | pm.RegisterMultiSelect("Projects", []string{}, []string{"Huge Refactoring"}, func(_ string, _, _ []string) ([]int, error) { |
| 167 | return []int{0}, nil |
| 168 | }) |
| 169 | |
| 170 | err := MetadataSurvey(pm, ios, repo, fetcher, &IssueMetadataState{}, gh.ProjectsV1Unsupported, nil, nil) |
| 171 | require.ErrorContains(t, err, "expected test error") |
| 172 | |
| 173 | require.False(t, fetcher.projectsV1Requested, "expected projectsV1 not to be requested") |
| 174 | }) |
| 175 | } |
| 176 | |
| 177 | type projectsV1MetadataFetcherSpy struct { |
| 178 | projectsV1Requested bool |
nothing calls this directly
no test coverage detected