forked from knative/func
-
Notifications
You must be signed in to change notification settings - Fork 0
/
function_git_unit_test.go
74 lines (70 loc) · 1.12 KB
/
function_git_unit_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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package function
import (
"testing"
)
func Test_validateGit(t *testing.T) {
tests := []struct {
name string
git Git
errs int
}{
{
"correct 'Git - only URL https",
Git{
URL: "https://myrepo/foo.git",
},
0,
},
{
"correct 'Git - only URL scp",
Git{
URL: "git@myrepo:foo.git",
},
0,
},
{
"correct 'Git - URL + revision",
Git{
URL: "https://myrepo/foo.git",
Revision: "mybranch",
},
0,
},
{
"correct 'Git - URL + context-dir",
Git{
URL: "https://myrepo/foo.git",
ContextDir: "my-folder",
},
0,
},
{
"correct 'Git - URL + revision & context-dir",
Git{
URL: "https://myrepo/foo.git",
Revision: "mybranch",
ContextDir: "my-folder",
},
0,
},
{
"incorrect 'Git - bad URL",
Git{
URL: "foo",
},
1,
},
{
"correct 'Git - not mandatory",
Git{},
0,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := validateGit(tt.git); len(got) != tt.errs {
t.Errorf("validateGit() = %v\n got %d errors but want %d", got, len(got), tt.errs)
}
})
}
}