forked from gitleaks/gitleaks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
leaks_test.go
54 lines (51 loc) · 922 Bytes
/
leaks_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
package main
import "testing"
func TestGetLocalRepoName(t *testing.T) {
cases := []struct {
name string
input string
expected string
}{
{
"Usual github url",
"https://github.com/usual/url",
"url",
},
{
"Usual github url with .git suffix",
"https://github.com/usual/url.git",
"url",
},
{
"personal git url",
"[email protected]:url.git",
"url",
},
{
"personal git url in sub folder",
"[email protected]:sub/url.git",
"url",
},
{
"ssh git url with port",
"ssh:https://[email protected]:2222/sub/url.git",
"url",
},
{
"local git in sub folder",
"local/url.git",
"url",
},
{
"local git in same folder",
"url.git",
"url",
},
}
for _, c := range cases {
actual := getLocalRepoName(c.input)
if actual != c.expected {
t.Errorf("'%s' failed. Input: '%s'; Expected: '%s'; Got: '%s'", c.input, c.name, c.expected, actual)
}
}
}