-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit_test.go
42 lines (39 loc) · 855 Bytes
/
git_test.go
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
package util
import (
"testing"
)
import "github.com/stretchr/testify/assert"
type G struct {
Ref string
Url string
Bra string
}
func TestRepoFromRef(t *testing.T) {
cases := []G{
{
Ref: "https://github.com/user/repo@branch",
Url: "https://github.com/user/repo",
Bra: "branch",
},
{
Ref: "https://git-hub.com/user.name/repo.name@br-0",
Url: "https://git-hub.com/user.name/repo.name",
Bra: "br-0",
},
{
Ref: "https://git_hub.com/user_name/repo-name.git",
Url: "https://git_hub.com/user_name/repo-name.git",
Bra: "",
},
{
Ref: "https://git_hub.com/user_name/repo-name.git@refs/heads/main",
Url: "https://git_hub.com/user_name/repo-name.git",
Bra: "refs/heads/main",
},
}
for _, c := range cases {
url, bra := RepoFromRef(c.Ref)
assert.Equal(t, c.Url, url)
assert.Equal(t, c.Bra, bra)
}
}