(t *testing.T)
| 162 | } |
| 163 | |
| 164 | func TestDefaultRun(t *testing.T) { |
| 165 | repo1, _ := ghrepo.FromFullName("OWNER/REPO") |
| 166 | repo2, _ := ghrepo.FromFullName("OWNER2/REPO2") |
| 167 | repo3, _ := ghrepo.FromFullName("OWNER3/REPO3") |
| 168 | repo4, _ := ghrepo.FromFullName("OWNER4/REPO4") |
| 169 | repo5, _ := ghrepo.FromFullName("OWNER5/REPO5") |
| 170 | repo6, _ := ghrepo.FromFullName("OWNER6/REPO6") |
| 171 | |
| 172 | tests := []struct { |
| 173 | name string |
| 174 | tty bool |
| 175 | opts SetDefaultOptions |
| 176 | remotes []*context.Remote |
| 177 | httpStubs func(*httpmock.Registry) |
| 178 | gitStubs func(*run.CommandStubber) |
| 179 | prompterStubs func(*prompter.PrompterMock) |
| 180 | wantStdout string |
| 181 | wantStderr string |
| 182 | wantErr bool |
| 183 | errMsg string |
| 184 | }{ |
| 185 | { |
| 186 | name: "unset mode with base resolved current default", |
| 187 | tty: true, |
| 188 | opts: SetDefaultOptions{UnsetMode: true}, |
| 189 | remotes: []*context.Remote{ |
| 190 | { |
| 191 | Remote: &git.Remote{Name: "origin", Resolved: "base"}, |
| 192 | Repo: repo1, |
| 193 | }, |
| 194 | }, |
| 195 | gitStubs: func(cs *run.CommandStubber) { |
| 196 | cs.Register(`git config --unset remote.origin.gh-resolved`, 0, "") |
| 197 | }, |
| 198 | wantStdout: "✓ Unset OWNER/REPO as default repository\n", |
| 199 | }, |
| 200 | { |
| 201 | name: "unset mode no current default", |
| 202 | tty: true, |
| 203 | opts: SetDefaultOptions{UnsetMode: true}, |
| 204 | remotes: []*context.Remote{ |
| 205 | { |
| 206 | Remote: &git.Remote{Name: "origin"}, |
| 207 | Repo: repo1, |
| 208 | }, |
| 209 | }, |
| 210 | wantStdout: "no default repository has been set\n", |
| 211 | }, |
| 212 | { |
| 213 | name: "tty view mode no current default", |
| 214 | tty: true, |
| 215 | opts: SetDefaultOptions{ViewMode: true}, |
| 216 | remotes: []*context.Remote{ |
| 217 | { |
| 218 | Remote: &git.Remote{Name: "origin"}, |
| 219 | Repo: repo1, |
| 220 | }, |
| 221 | }, |
nothing calls this directly
no test coverage detected