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

Function TestParseArtifactArgs

pkg/cmd/issue/artifact/shared/shared_test.go:173–437  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

171}
172
173func TestParseArtifactArgs(t *testing.T) {
174 // The spec's artifacts 2 and 5 on issue 142, and 1 on issue 137.
175 const (
176 oauthPlanURL = "https://github.com/monalisa/monas-cafe/issues/142/artifacts/2"
177 baristaURL = "https://github.com/monalisa/monas-cafe/issues/142/artifacts/5"
178 approvedURL = "https://github.com/monalisa/monas-cafe/issues/137/artifacts/1"
179 )
180
181 tests := []struct {
182 name string
183 args []string
184 issueAlone bool
185 wantIssue int
186 wantRepo string
187 wantNumbers []int
188 wantBaseRepoCalls int
189 wantErr string
190 }{
191 {
192 name: "an issue and artifact numbers, in argument order",
193 args: []string{"142", "5", "2"},
194 wantIssue: 142,
195 wantRepo: "github.com/OWNER/REPO",
196 wantNumbers: []int{5, 2},
197 wantBaseRepoCalls: 1,
198 },
199 {
200 name: "an issue URL names its repository",
201 args: []string{"https://github.com/monalisa/monas-cafe/issues/142", "2"},
202 wantIssue: 142,
203 wantRepo: "github.com/monalisa/monas-cafe",
204 wantNumbers: []int{2},
205 },
206 {
207 name: "an artifact URL names its repository, issue and number",
208 args: []string{oauthPlanURL},
209 wantIssue: 142,
210 wantRepo: "github.com/monalisa/monas-cafe",
211 wantNumbers: []int{2},
212 },
213 {
214 name: "artifact URLs on one issue, in argument order",
215 args: []string{baristaURL, oauthPlanURL},
216 wantIssue: 142,
217 wantRepo: "github.com/monalisa/monas-cafe",
218 wantNumbers: []int{5, 2},
219 },
220 {
221 name: "an artifact URL on a ghe.com host",
222 args: []string{"https://monas-cafe.ghe.com/monalisa/monas-cafe/issues/142/artifacts/3"},
223 wantIssue: 142,
224 wantRepo: "monas-cafe.ghe.com/monalisa/monas-cafe",
225 wantNumbers: []int{3},
226 },
227 {
228 name: "an http artifact URL, whose query and fragment are ignored",
229 args: []string{"http://github.com/monalisa/monas-cafe/issues/142/artifacts/2?tab=history#step-2"},
230 wantIssue: 142,

Callers

nothing calls this directly

Calls 6

NewFunction · 0.92
FullNameFunction · 0.92
ParseArtifactArgsFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65
RepoHostMethod · 0.65

Tested by

no test coverage detected