forked from hashicorp/go-getter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
detect_git_test.go
58 lines (54 loc) · 1.33 KB
/
detect_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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package getter
import (
"testing"
)
func TestGitDetector(t *testing.T) {
cases := []struct {
Input string
Output string
}{
{"[email protected]:hashicorp/foo.git", "git::ssh://[email protected]/hashicorp/foo.git"},
{
"[email protected]:org/project.git?ref=test-branch",
"git::ssh://[email protected]/org/project.git?ref=test-branch",
},
{
"[email protected]:hashicorp/foo.git//bar",
"git::ssh://[email protected]/hashicorp/foo.git//bar",
},
{
"[email protected]:hashicorp/foo.git?foo=bar",
"git::ssh://[email protected]/hashicorp/foo.git?foo=bar",
},
{
"[email protected]:org/project.git",
"git::ssh://[email protected]/org/project.git",
},
{
"[email protected]:org/project.git?ref=test-branch",
"git::ssh://[email protected]/org/project.git?ref=test-branch",
},
{
"[email protected]:org/project.git//module/a",
"git::ssh://[email protected]/org/project.git//module/a",
},
{
"[email protected]:org/project.git//module/a?ref=test-branch",
"git::ssh://[email protected]/org/project.git//module/a?ref=test-branch",
},
}
pwd := "/pwd"
f := new(GitDetector)
for i, tc := range cases {
output, ok, err := f.Detect(tc.Input, pwd)
if err != nil {
t.Fatalf("err: %s", err)
}
if !ok {
t.Fatal("not ok")
}
if output != tc.Output {
t.Fatalf("%d: bad: %#v", i, output)
}
}
}