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

Function Test_checkoutRun

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

Source from the content-addressed store, hash-verified

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