Merge pull request #7329 from fenggw-fnst/work

Add corresponding unit test to the function in resolver.go
pull/7500/head
Matthew Fisher 5 years ago committed by GitHub
commit 98cae60cff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -216,3 +216,61 @@ func TestHashReq(t *testing.T) {
})
}
}
func TestGetLocalPath(t *testing.T) {
tests := []struct {
name string
repo string
chartpath string
expect string
err bool
}{
{
name: "absolute path",
repo: "file:////proc",
expect: "/proc",
},
{
name: "relative path",
repo: "file://../../../../cmd/helm/testdata/testcharts/signtest",
chartpath: "foo/bar",
expect: "../../cmd/helm/testdata/testcharts/signtest",
},
{
name: "current directory path",
repo: "../charts/localdependency",
chartpath: "testdata/chartpath/charts",
expect: "testdata/chartpath/charts/localdependency",
},
{
name: "invalid local path",
repo: "file://../testdata/notexist",
chartpath: "testdata/chartpath",
err: true,
},
{
name: "invalid path under current directory",
repo: "../charts/nonexistentdependency",
chartpath: "testdata/chartpath/charts",
err: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
p, err := GetLocalPath(tt.repo, tt.chartpath)
if err != nil {
if tt.err {
return
}
t.Fatal(err)
}
if tt.err {
t.Fatalf("Expected error in test %q", tt.name)
}
if p != tt.expect {
t.Errorf("%q: expected %q, got %q", tt.name, tt.expect, p)
}
})
}
}

Loading…
Cancel
Save