(t *testing.T)
| 121 | } |
| 122 | |
| 123 | func TestNewCmdListBaseRepoFuncs(t *testing.T) { |
| 124 | multipleRemotes := ghContext.Remotes{ |
| 125 | &ghContext.Remote{ |
| 126 | Remote: &git.Remote{ |
| 127 | Name: "origin", |
| 128 | }, |
| 129 | Repo: ghrepo.New("owner", "fork"), |
| 130 | }, |
| 131 | &ghContext.Remote{ |
| 132 | Remote: &git.Remote{ |
| 133 | Name: "upstream", |
| 134 | }, |
| 135 | Repo: ghrepo.New("owner", "repo"), |
| 136 | }, |
| 137 | } |
| 138 | |
| 139 | singleRemote := ghContext.Remotes{ |
| 140 | &ghContext.Remote{ |
| 141 | Remote: &git.Remote{ |
| 142 | Name: "origin", |
| 143 | }, |
| 144 | Repo: ghrepo.New("owner", "repo"), |
| 145 | }, |
| 146 | } |
| 147 | |
| 148 | tests := []struct { |
| 149 | name string |
| 150 | args string |
| 151 | env map[string]string |
| 152 | remotes ghContext.Remotes |
| 153 | prompterStubs func(*prompter.MockPrompter) |
| 154 | wantRepo ghrepo.Interface |
| 155 | wantErr error |
| 156 | }{ |
| 157 | { |
| 158 | name: "when there is a repo flag provided, the factory base repo func is used", |
| 159 | args: "--repo owner/repo", |
| 160 | remotes: multipleRemotes, |
| 161 | wantRepo: ghrepo.New("owner", "repo"), |
| 162 | }, |
| 163 | { |
| 164 | name: "when GH_REPO env var is provided, the factory base repo func is used", |
| 165 | env: map[string]string{ |
| 166 | "GH_REPO": "owner/repo", |
| 167 | }, |
| 168 | remotes: multipleRemotes, |
| 169 | wantRepo: ghrepo.New("owner", "repo"), |
| 170 | }, |
| 171 | { |
| 172 | name: "when there is no repo flag or GH_REPO env var provided, and no prompting, the base func requiring no ambiguity is used", |
| 173 | args: "", |
| 174 | remotes: multipleRemotes, |
| 175 | wantErr: shared.AmbiguousBaseRepoError{ |
| 176 | Remotes: multipleRemotes, |
| 177 | }, |
| 178 | }, |
| 179 | { |
| 180 | name: "when there is no repo flag or GH_REPO env provided, and there is a single remote, the factory base repo func is used", |
nothing calls this directly
no test coverage detected