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

Function Test_isSameRef

pkg/cmd/pr/create/create_test.go:3511–3579  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3509}
3510
3511func Test_isSameRef(t *testing.T) {
3512 tests := []struct {
3513 name string
3514 refs creationRefs
3515 expected bool
3516 }{
3517 {
3518 name: "same branch in same repo",
3519 refs: skipPushRefs{
3520 qualifiedHeadRef: shared.NewQualifiedHeadRefWithoutOwner("main"),
3521 baseRefs: baseRefs{
3522 baseBranchName: "main",
3523 },
3524 },
3525 expected: true,
3526 },
3527 {
3528 name: "different branches in same repo",
3529 refs: skipPushRefs{
3530 qualifiedHeadRef: shared.NewQualifiedHeadRefWithoutOwner("feature"),
3531 baseRefs: baseRefs{
3532 baseBranchName: "main",
3533 },
3534 },
3535 expected: false,
3536 },
3537 {
3538 name: "same branch name in different repos (cross-repo PR)",
3539 refs: skipPushRefs{
3540 qualifiedHeadRef: shared.NewQualifiedHeadRef("other-owner", "main"),
3541 baseRefs: baseRefs{
3542 baseBranchName: "main",
3543 },
3544 },
3545 expected: false,
3546 },
3547 {
3548 name: "pushableRefs same branch same repo",
3549 refs: pushableRefs{
3550 headRepo: ghrepo.New("OWNER", "REPO"),
3551 headBranchName: "main",
3552 baseRefs: baseRefs{
3553 baseRepo: api.InitRepoHostname(&api.Repository{Name: "REPO", Owner: api.RepositoryOwner{Login: "OWNER"}}, "github.com"),
3554 baseBranchName: "main",
3555 },
3556 },
3557 expected: true,
3558 },
3559 {
3560 name: "pushableRefs same branch different repos (fork)",
3561 refs: pushableRefs{
3562 headRepo: ghrepo.New("FORK-OWNER", "REPO"),
3563 headBranchName: "main",
3564 baseRefs: baseRefs{
3565 baseRepo: api.InitRepoHostname(&api.Repository{Name: "REPO", Owner: api.RepositoryOwner{Login: "OWNER"}}, "github.com"),
3566 baseBranchName: "main",
3567 },
3568 },

Callers

nothing calls this directly

Calls 7

NewQualifiedHeadRefFunction · 0.92
NewFunction · 0.92
InitRepoHostnameFunction · 0.92
isSameRefFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected