(t *testing.T)
| 143 | } |
| 144 | |
| 145 | func TestNewCmdDeleteBaseRepoFuncs(t *testing.T) { |
| 146 | multipleRemotes := ghContext.Remotes{ |
| 147 | &ghContext.Remote{ |
| 148 | Remote: &git.Remote{ |
| 149 | Name: "origin", |
| 150 | }, |
| 151 | Repo: ghrepo.New("owner", "fork"), |
| 152 | }, |
| 153 | &ghContext.Remote{ |
| 154 | Remote: &git.Remote{ |
| 155 | Name: "upstream", |
| 156 | }, |
| 157 | Repo: ghrepo.New("owner", "repo"), |
| 158 | }, |
| 159 | } |
| 160 | |
| 161 | singleRemote := ghContext.Remotes{ |
| 162 | &ghContext.Remote{ |
| 163 | Remote: &git.Remote{ |
| 164 | Name: "origin", |
| 165 | }, |
| 166 | Repo: ghrepo.New("owner", "repo"), |
| 167 | }, |
| 168 | } |
| 169 | |
| 170 | tests := []struct { |
| 171 | name string |
| 172 | args string |
| 173 | env map[string]string |
| 174 | remotes ghContext.Remotes |
| 175 | prompterStubs func(*prompter.MockPrompter) |
| 176 | wantRepo ghrepo.Interface |
| 177 | wantErr error |
| 178 | }{ |
| 179 | { |
| 180 | name: "when there is a repo flag provided, the factory base repo func is used", |
| 181 | args: "SECRET_NAME --repo owner/repo", |
| 182 | remotes: multipleRemotes, |
| 183 | wantRepo: ghrepo.New("owner", "repo"), |
| 184 | }, |
| 185 | { |
| 186 | name: "when GH_REPO env var is provided, the factory base repo func is used", |
| 187 | args: "SECRET_NAME", |
| 188 | env: map[string]string{ |
| 189 | "GH_REPO": "owner/repo", |
| 190 | }, |
| 191 | remotes: multipleRemotes, |
| 192 | wantRepo: ghrepo.New("owner", "repo"), |
| 193 | }, |
| 194 | { |
| 195 | name: "when there is no repo flag or GH_REPO env var provided, and no prompting, the base func requiring no ambiguity is used", |
| 196 | args: "SECRET_NAME", |
| 197 | remotes: multipleRemotes, |
| 198 | wantErr: shared.AmbiguousBaseRepoError{ |
| 199 | Remotes: multipleRemotes, |
| 200 | }, |
| 201 | }, |
| 202 | { |
nothing calls this directly
no test coverage detected