MCPcopy
hub / github.com/cli/cli / TestPRCheckout_sameRepo

Function TestPRCheckout_sameRepo

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

Source from the content-addressed store, hash-verified

514}
515
516func TestPRCheckout_sameRepo(t *testing.T) {
517 http := &httpmock.Registry{}
518 defer http.Verify(t)
519
520 baseRepo, pr := stubPR("OWNER/REPO", "OWNER/REPO:feature")
521 finder := shared.StubFinderForRunCommandStyleTests(t, "123", pr, baseRepo)
522 finder.ExpectFields([]string{"number", "headRefName", "headRepository", "headRepositoryOwner", "isCrossRepository", "maintainerCanModify"})
523
524 cs, cmdTeardown := run.Stub()
525 defer cmdTeardown(t)
526
527 cs.Register(`git fetch origin \+refs/heads/feature:refs/remotes/origin/feature --no-tags`, 0, "")
528 cs.Register(`git show-ref --verify -- refs/heads/feature`, 1, "")
529 cs.Register(`git checkout -b feature --track origin/feature`, 0, "")
530
531 output, err := runCommand(http, nil, "master", `123`, baseRepo)
532 assert.NoError(t, err)
533 assert.Equal(t, "", output.String())
534 assert.Equal(t, "", output.Stderr())
535}
536
537func TestPRCheckout_existingBranch(t *testing.T) {
538 http := &httpmock.Registry{}

Callers

nothing calls this directly

Calls 10

VerifyMethod · 0.95
StubFunction · 0.92
EqualMethod · 0.80
StderrMethod · 0.80
stubPRFunction · 0.70
runCommandFunction · 0.70
ExpectFieldsMethod · 0.45
RegisterMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected