MCPcopy
hub / github.com/cli/cli / TestDefaultRun

Function TestDefaultRun

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

Source from the content-addressed store, hash-verified

162}
163
164func 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 },

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