File: detect_test.go

package info (click to toggle)
golang-github-hashicorp-go-getter 0.0~git20160316.0.575ec4e-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 904 kB
  • ctags: 238
  • sloc: sh: 286; makefile: 5
file content (51 lines) | stat: -rw-r--r-- 956 bytes parent folder | download
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
package getter

import (
	"testing"
)

func TestDetect(t *testing.T) {
	cases := []struct {
		Input  string
		Pwd    string
		Output string
		Err    bool
	}{
		{"./foo", "/foo", "file:///foo/foo", false},
		{"git::./foo", "/foo", "git::file:///foo/foo", false},
		{
			"git::github.com/hashicorp/foo",
			"",
			"git::https://github.com/hashicorp/foo.git",
			false,
		},
		{
			"./foo//bar",
			"/foo",
			"file:///foo/foo//bar",
			false,
		},
		{
			"git::github.com/hashicorp/foo//bar",
			"",
			"git::https://github.com/hashicorp/foo.git//bar",
			false,
		},
		{
			"git::https://github.com/hashicorp/consul.git",
			"",
			"git::https://github.com/hashicorp/consul.git",
			false,
		},
	}

	for i, tc := range cases {
		output, err := Detect(tc.Input, tc.Pwd, Detectors)
		if err != nil != tc.Err {
			t.Fatalf("%d: bad err: %s", i, err)
		}
		if output != tc.Output {
			t.Fatalf("%d: bad output: %s\nexpected: %s", i, output, tc.Output)
		}
	}
}