(t *testing.T)
| 283 | } |
| 284 | |
| 285 | func TestNewCmdSetBaseRepoFuncs(t *testing.T) { |
| 286 | multipleRemotes := ghContext.Remotes{ |
| 287 | &ghContext.Remote{ |
| 288 | Remote: &git.Remote{ |
| 289 | Name: "origin", |
| 290 | }, |
| 291 | Repo: ghrepo.New("owner", "fork"), |
| 292 | }, |
| 293 | &ghContext.Remote{ |
| 294 | Remote: &git.Remote{ |
| 295 | Name: "upstream", |
| 296 | }, |
| 297 | Repo: ghrepo.New("owner", "repo"), |
| 298 | }, |
| 299 | } |
| 300 | |
| 301 | singleRemote := ghContext.Remotes{ |
| 302 | &ghContext.Remote{ |
| 303 | Remote: &git.Remote{ |
| 304 | Name: "origin", |
| 305 | }, |
| 306 | Repo: ghrepo.New("owner", "repo"), |
| 307 | }, |
| 308 | } |
| 309 | |
| 310 | tests := []struct { |
| 311 | name string |
| 312 | args string |
| 313 | env map[string]string |
| 314 | remotes ghContext.Remotes |
| 315 | prompterStubs func(*prompter.MockPrompter) |
| 316 | wantRepo ghrepo.Interface |
| 317 | wantErr error |
| 318 | }{ |
| 319 | { |
| 320 | name: "when there is a repo flag provided, the factory base repo func is used", |
| 321 | args: "SECRET_NAME --repo owner/repo", |
| 322 | remotes: multipleRemotes, |
| 323 | wantRepo: ghrepo.New("owner", "repo"), |
| 324 | }, |
| 325 | { |
| 326 | name: "when GH_REPO env var is provided, the factory base repo func is used", |
| 327 | args: "SECRET_NAME", |
| 328 | env: map[string]string{ |
| 329 | "GH_REPO": "owner/repo", |
| 330 | }, |
| 331 | remotes: multipleRemotes, |
| 332 | wantRepo: ghrepo.New("owner", "repo"), |
| 333 | }, |
| 334 | { |
| 335 | name: "when there is no repo flag or GH_REPO env var provided, and no prompting, the base func requiring no ambiguity is used", |
| 336 | args: "SECRET_NAME", |
| 337 | remotes: multipleRemotes, |
| 338 | wantErr: shared.AmbiguousBaseRepoError{ |
| 339 | Remotes: multipleRemotes, |
| 340 | }, |
| 341 | }, |
| 342 | { |
nothing calls this directly
no test coverage detected