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

Function TestDefaultRun

pkg/cmd/repo/setdefault/setdefault_test.go:178–568  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 15

RegisterMethod · 0.95
VerifyMethod · 0.95
FromFullNameFunction · 0.92
GraphQLFunction · 0.92
StringResponseFunction · 0.92
AssertOptionsFunction · 0.92
IndexForFunction · 0.92
NoSuchPromptErrFunction · 0.92
GraphQLQueryFunction · 0.92
TestFunction · 0.92
StubFunction · 0.92
setDefaultRunFunction · 0.85

Tested by

no test coverage detected