MCPcopy Index your code
hub / github.com/cli/cli / Test_checkoutRun

Function Test_checkoutRun

pkg/cmd/pr/checkout/checkout_test.go:166–363  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

164}
165
166func Test_checkoutRun(t *testing.T) {
167 tests := []struct {
168 name string
169 opts *CheckoutOptions
170
171 httpStubs func(*httpmock.Registry)
172 runStubs func(*run.CommandStubber)
173 promptStubs func(*prompter.MockPrompter)
174
175 remotes map[string]string
176 wantStdout string
177 wantStderr string
178 wantErr bool
179 errMsg string
180 }{
181 {
182 name: "checkout with ssh remote URL",
183 opts: &CheckoutOptions{
184 PRResolver: func() PRResolver {
185 baseRepo, pr := stubPR("OWNER/REPO:master", "OWNER/REPO:feature")
186 return &stubPRResolver{
187 pr: pr,
188 baseRepo: baseRepo,
189 }
190 }(),
191 Config: func() (gh.Config, error) {
192 return config.NewBlankConfig(), nil
193 },
194 Branch: func() (string, error) {
195 return "main", nil
196 },
197 },
198 remotes: map[string]string{
199 "origin": "OWNER/REPO",
200 },
201 runStubs: func(cs *run.CommandStubber) {
202 cs.Register(`git show-ref --verify -- refs/heads/feature`, 1, "")
203 cs.Register(`git fetch origin \+refs/heads/feature:refs/remotes/origin/feature --no-tags`, 0, "")
204 cs.Register(`git checkout -b feature --track origin/feature`, 0, "")
205 },
206 },
207 {
208 name: "fork repo was deleted",
209 opts: &CheckoutOptions{
210 PRResolver: func() PRResolver {
211 baseRepo, pr := stubPR("OWNER/REPO:master", "OWNER/REPO:feature")
212 pr.MaintainerCanModify = true
213 pr.HeadRepository = nil
214 return &stubPRResolver{
215 pr: pr,
216 baseRepo: baseRepo,
217 }
218 }(),
219 Config: func() (gh.Config, error) {
220 return config.NewBlankConfig(), nil
221 },
222 Branch: func() (string, error) {
223 return "main", nil

Callers

nothing calls this directly

Calls 13

VerifyMethod · 0.95
NewBlankConfigFunction · 0.92
TestFunction · 0.92
StubFunction · 0.92
FromFullNameFunction · 0.92
checkoutRunFunction · 0.85
EqualMethod · 0.80
stubPRFunction · 0.70
RunMethod · 0.65
ErrorfMethod · 0.65
RegisterMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected