MCPcopy
hub / github.com/cli/cli / Test_isSameRef

Function Test_isSameRef

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

Source from the content-addressed store, hash-verified

3065}
3066
3067func Test_isSameRef(t *testing.T) {
3068 tests := []struct {
3069 name string
3070 refs creationRefs
3071 expected bool
3072 }{
3073 {
3074 name: "same branch in same repo",
3075 refs: skipPushRefs{
3076 qualifiedHeadRef: shared.NewQualifiedHeadRefWithoutOwner("main"),
3077 baseRefs: baseRefs{
3078 baseBranchName: "main",
3079 },
3080 },
3081 expected: true,
3082 },
3083 {
3084 name: "different branches in same repo",
3085 refs: skipPushRefs{
3086 qualifiedHeadRef: shared.NewQualifiedHeadRefWithoutOwner("feature"),
3087 baseRefs: baseRefs{
3088 baseBranchName: "main",
3089 },
3090 },
3091 expected: false,
3092 },
3093 {
3094 name: "same branch name in different repos (cross-repo PR)",
3095 refs: skipPushRefs{
3096 qualifiedHeadRef: shared.NewQualifiedHeadRef("other-owner", "main"),
3097 baseRefs: baseRefs{
3098 baseBranchName: "main",
3099 },
3100 },
3101 expected: false,
3102 },
3103 {
3104 name: "pushableRefs same branch same repo",
3105 refs: pushableRefs{
3106 headRepo: ghrepo.New("OWNER", "REPO"),
3107 headBranchName: "main",
3108 baseRefs: baseRefs{
3109 baseRepo: api.InitRepoHostname(&api.Repository{Name: "REPO", Owner: api.RepositoryOwner{Login: "OWNER"}}, "github.com"),
3110 baseBranchName: "main",
3111 },
3112 },
3113 expected: true,
3114 },
3115 {
3116 name: "pushableRefs same branch different repos (fork)",
3117 refs: pushableRefs{
3118 headRepo: ghrepo.New("FORK-OWNER", "REPO"),
3119 headBranchName: "main",
3120 baseRefs: baseRefs{
3121 baseRepo: api.InitRepoHostname(&api.Repository{Name: "REPO", Owner: api.RepositoryOwner{Login: "OWNER"}}, "github.com"),
3122 baseBranchName: "main",
3123 },
3124 },

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