summaryrefslogtreecommitdiff
path: root/data/datasource_git_test.go
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2021-04-03 13:18:17 -0400
committerDave Henderson <dhenderson@gmail.com>2021-04-03 14:23:00 -0400
commitd334a3619a9897ff43b76b8f60fa1a0a41b9cbe9 (patch)
tree97f9fe27182604e41f08183fc42a2e4b4bded7ba /data/datasource_git_test.go
parent507d41ae8a2536584eb032c98abc46496a77ea86 (diff)
Update linting and fix field alignment issues
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'data/datasource_git_test.go')
-rw-r--r--data/datasource_git_test.go52
1 files changed, 28 insertions, 24 deletions
diff --git a/data/datasource_git_test.go b/data/datasource_git_test.go
index 73780184..f48393c3 100644
--- a/data/datasource_git_test.go
+++ b/data/datasource_git_test.go
@@ -100,78 +100,78 @@ func TestParseGitPath(t *testing.T) {
data := []struct {
url string
- args []string
+ args string
repo, path string
}{
{"git+https://github.com/hairyhenderson/gomplate//docs-src/content/functions/aws.yml",
- nil,
+ "",
"git+https://github.com/hairyhenderson/gomplate",
"/docs-src/content/functions/aws.yml"},
{"git+ssh://github.com/hairyhenderson/gomplate.git",
- nil,
+ "",
"git+ssh://github.com/hairyhenderson/gomplate.git",
"/"},
{"https://github.com",
- nil,
+ "",
"https://github.com",
"/"},
{"git://example.com/foo//file.txt#someref",
- nil,
+ "",
"git://example.com/foo#someref", "/file.txt"},
{"git+file:///home/foo/repo//file.txt#someref",
- nil,
+ "",
"git+file:///home/foo/repo#someref", "/file.txt"},
{"git+file:///repo",
- nil,
+ "",
"git+file:///repo", "/"},
{"git+file:///foo//foo",
- nil,
+ "",
"git+file:///foo", "/foo"},
{"git+file:///foo//foo",
- []string{"/bar"},
+ "/bar",
"git+file:///foo", "/foo/bar"},
{"git+file:///foo//bar",
// in this case the // is meaningless
- []string{"/baz//qux"},
+ "/baz//qux",
"git+file:///foo", "/bar/baz/qux"},
{"git+https://example.com/foo",
- []string{"/bar"},
+ "/bar",
"git+https://example.com/foo/bar", "/"},
{"git+https://example.com/foo",
- []string{"//bar"},
+ "//bar",
"git+https://example.com/foo", "/bar"},
{"git+https://example.com//foo",
- []string{"/bar"},
+ "/bar",
"git+https://example.com", "/foo/bar"},
{"git+https://example.com/foo//bar",
- []string{"//baz"},
+ "//baz",
"git+https://example.com/foo", "/bar/baz"},
{"git+https://example.com/foo",
- []string{"/bar//baz"},
+ "/bar//baz",
"git+https://example.com/foo/bar", "/baz"},
{"git+https://example.com/foo?type=t",
- []string{"/bar//baz"},
+ "/bar//baz",
"git+https://example.com/foo/bar?type=t", "/baz"},
{"git+https://example.com/foo#master",
- []string{"/bar//baz"},
+ "/bar//baz",
"git+https://example.com/foo/bar#master", "/baz"},
{"git+https://example.com/foo",
- []string{"/bar//baz?type=t"},
+ "/bar//baz?type=t",
"git+https://example.com/foo/bar?type=t", "/baz"},
{"git+https://example.com/foo",
- []string{"/bar//baz#master"},
+ "/bar//baz#master",
"git+https://example.com/foo/bar#master", "/baz"},
{"git+https://example.com/foo",
- []string{"//bar?type=t"},
+ "//bar?type=t",
"git+https://example.com/foo?type=t", "/bar"},
{"git+https://example.com/foo",
- []string{"//bar#master"},
+ "//bar#master",
"git+https://example.com/foo#master", "/bar"},
{"git+https://example.com/foo?type=t",
- []string{"//bar#master"},
+ "//bar#master",
"git+https://example.com/foo?type=t#master", "/bar"},
{"git+https://example.com/foo?type=t#v1",
- []string{"//bar?type=j#v2"},
+ "//bar?type=j#v2",
"git+https://example.com/foo?type=t&type=j#v2", "/bar"},
}
@@ -180,7 +180,11 @@ func TestParseGitPath(t *testing.T) {
t.Run(fmt.Sprintf("%d:(%q,%q)==(%q,%q)", i, d.url, d.args, d.repo, d.path), func(t *testing.T) {
t.Parallel()
u, _ := url.Parse(d.url)
- repo, path, err := g.parseGitPath(u, d.args...)
+ args := []string{d.args}
+ if d.args == "" {
+ args = nil
+ }
+ repo, path, err := g.parseGitPath(u, args...)
assert.NilError(t, err)
assert.Equal(t, d.repo, repo.String())
assert.Equal(t, d.path, path)