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

Function Test_isSameRef

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

Source from the content-addressed store, hash-verified

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

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