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

Function Test_isSameRef

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

Source from the content-addressed store, hash-verified

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

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