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

Function Test_checkoutRun

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 14

VerifyMethod · 0.95
NewMockConfigFunction · 0.92
TestFunction · 0.92
StubFunction · 0.92
FromFullNameFunction · 0.92
checkoutRunFunction · 0.85
SetStdoutTTYMethod · 0.80
EqualMethod · 0.80
stubPRFunction · 0.70
RunMethod · 0.65
ErrorfMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected