1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
package git
import (
"testing"
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
)
func TestCheckRefFormat(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
for _, tc := range []struct {
desc string
tagName string
ok bool
err error
}{
// Just trivial tests here, most of this is tested in
// internal/gitaly/service/operations/tags_test.go
{
desc: "unqualified name",
tagName: "my-name",
ok: false,
err: CheckRefFormatError{},
},
{
desc: "fully-qualified name",
tagName: "refs/heads/my-name",
ok: true,
err: nil,
},
{
desc: "basic tag",
tagName: "refs/tags/my-tag",
ok: true,
err: nil,
},
{
desc: "invalid tag",
tagName: "refs/tags/my tag",
ok: false,
err: CheckRefFormatError{},
},
} {
t.Run(tc.desc, func(t *testing.T) {
ok, err := CheckRefFormat(ctx, tc.tagName)
require.Equal(t, tc.err, err)
require.Equal(t, tc.ok, ok)
})
}
}
|