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

Function Test_isSameRef

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

Source from the content-addressed store, hash-verified

3485}
3486
3487func Test_isSameRef(t *testing.T) {
3488 tests := []struct {
3489 name string
3490 refs creationRefs
3491 expected bool
3492 }{
3493 {
3494 name: "same branch in same repo",
3495 refs: skipPushRefs{
3496 qualifiedHeadRef: shared.NewQualifiedHeadRefWithoutOwner("main"),
3497 baseRefs: baseRefs{
3498 baseBranchName: "main",
3499 },
3500 },
3501 expected: true,
3502 },
3503 {
3504 name: "different branches in same repo",
3505 refs: skipPushRefs{
3506 qualifiedHeadRef: shared.NewQualifiedHeadRefWithoutOwner("feature"),
3507 baseRefs: baseRefs{
3508 baseBranchName: "main",
3509 },
3510 },
3511 expected: false,
3512 },
3513 {
3514 name: "same branch name in different repos (cross-repo PR)",
3515 refs: skipPushRefs{
3516 qualifiedHeadRef: shared.NewQualifiedHeadRef("other-owner", "main"),
3517 baseRefs: baseRefs{
3518 baseBranchName: "main",
3519 },
3520 },
3521 expected: false,
3522 },
3523 {
3524 name: "pushableRefs same branch same repo",
3525 refs: pushableRefs{
3526 headRepo: ghrepo.New("OWNER", "REPO"),
3527 headBranchName: "main",
3528 baseRefs: baseRefs{
3529 baseRepo: api.InitRepoHostname(&api.Repository{Name: "REPO", Owner: api.RepositoryOwner{Login: "OWNER"}}, "github.com"),
3530 baseBranchName: "main",
3531 },
3532 },
3533 expected: true,
3534 },
3535 {
3536 name: "pushableRefs same branch different repos (fork)",
3537 refs: pushableRefs{
3538 headRepo: ghrepo.New("FORK-OWNER", "REPO"),
3539 headBranchName: "main",
3540 baseRefs: baseRefs{
3541 baseRepo: api.InitRepoHostname(&api.Repository{Name: "REPO", Owner: api.RepositoryOwner{Login: "OWNER"}}, "github.com"),
3542 baseBranchName: "main",
3543 },
3544 },

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