Skip to content

Commit a278cca

Browse files
committed
repo_reference: adds more tests
1 parent 25725f4 commit a278cca

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

repo_reference_test.go

+48
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ func TestRepository_HasReference(t *testing.T) {
6262
ref: RefsHeads + "master",
6363
expVal: true,
6464
},
65+
{
66+
ref: RefsTags + "v1.0.0",
67+
expVal: true,
68+
},
6569
{
6670
ref: "master",
6771
expVal: false,
@@ -74,6 +78,50 @@ func TestRepository_HasReference(t *testing.T) {
7478
}
7579
}
7680

81+
func TestRepository_HasBranch(t *testing.T) {
82+
tests := []struct {
83+
ref string
84+
opt ShowRefVerifyOptions
85+
expVal bool
86+
}{
87+
{
88+
ref: "master",
89+
expVal: true,
90+
},
91+
{
92+
ref: RefsHeads + "master",
93+
expVal: false,
94+
},
95+
}
96+
for _, test := range tests {
97+
t.Run("", func(t *testing.T) {
98+
assert.Equal(t, test.expVal, testrepo.HasBranch(test.ref, test.opt))
99+
})
100+
}
101+
}
102+
103+
func TestRepository_HasTag(t *testing.T) {
104+
tests := []struct {
105+
ref string
106+
opt ShowRefVerifyOptions
107+
expVal bool
108+
}{
109+
{
110+
ref: "v1.0.0",
111+
expVal: true,
112+
},
113+
{
114+
ref: RefsTags + "v1.0.0",
115+
expVal: false,
116+
},
117+
}
118+
for _, test := range tests {
119+
t.Run("", func(t *testing.T) {
120+
assert.Equal(t, test.expVal, testrepo.HasTag(test.ref, test.opt))
121+
})
122+
}
123+
}
124+
77125
func TestRepository_SymbolicRef(t *testing.T) {
78126
r, cleanup, err := setupTempRepo()
79127
if err != nil {

0 commit comments

Comments
 (0)