-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils_test.go
55 lines (48 loc) · 1.13 KB
/
utils_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
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import "testing"
func TestIsSshUrl(t *testing.T) {
testCases := []struct {
url string
wantBool bool
}{
{"[email protected]:user/repo.git", true},
{"invalid-url", false},
}
for _, tc := range testCases {
gotBool := isSshUrl(tc.url)
if gotBool != tc.wantBool {
t.Errorf("isSshUrl(%s): expected: %v, got: %v", tc.url, tc.wantBool, gotBool)
}
}
}
func TestIsHttpUrl(t *testing.T) {
testCases := []struct {
url string
wantBool bool
}{
{"https://github.com/user/repo.git", true},
{"invalid-url", false},
}
for _, tc := range testCases {
gotBool := isHttpUrl(tc.url)
if gotBool != tc.wantBool {
t.Errorf("isHttpUrl(%s): expected: %v, got: %v", tc.url, tc.wantBool, gotBool)
}
}
}
func TestIsValidGitUrl(t *testing.T) {
testCases := []struct {
url string
wantBool bool
}{
{"[email protected]:user/repo.git", true},
{"https://github.com/user/repo.git", true},
{".gitinvalid-url", false},
}
for _, tc := range testCases {
gotBool := isValidGitUrl(tc.url)
if gotBool != tc.wantBool {
t.Errorf("isValidGitUrl(%s): expected: %v, got: %v", tc.url, tc.wantBool, gotBool)
}
}
}