|
|
|
|
@ -15,32 +15,50 @@ package installer // import "helm.sh/helm/v4/internal/plugin/installer"
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"helm.sh/helm/v4/pkg/helmpath"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestPath(t *testing.T) {
|
|
|
|
|
func Test_Path(t *testing.T) {
|
|
|
|
|
tests := []struct {
|
|
|
|
|
name string
|
|
|
|
|
source string
|
|
|
|
|
helmPluginsDir string
|
|
|
|
|
expectPath string
|
|
|
|
|
}{
|
|
|
|
|
{
|
|
|
|
|
name: "empty source default helm plugins dir",
|
|
|
|
|
source: "",
|
|
|
|
|
helmPluginsDir: "",
|
|
|
|
|
expectPath: "",
|
|
|
|
|
}, {
|
|
|
|
|
name: "default helm plugins dir",
|
|
|
|
|
source: "https://github.com/adamreese/helm-env",
|
|
|
|
|
helmPluginsDir: "",
|
|
|
|
|
expectPath: helmpath.DataPath("plugins", "helm-env"),
|
|
|
|
|
}, {
|
|
|
|
|
name: "empty source custom helm plugins dir",
|
|
|
|
|
source: "",
|
|
|
|
|
helmPluginsDir: "/helm/data/plugins",
|
|
|
|
|
helmPluginsDir: "/foo/bar",
|
|
|
|
|
expectPath: "",
|
|
|
|
|
}, {
|
|
|
|
|
source: "https://github.com/jkroepke/helm-secrets",
|
|
|
|
|
helmPluginsDir: "/helm/data/plugins",
|
|
|
|
|
expectPath: "/helm/data/plugins/helm-secrets",
|
|
|
|
|
name: "custom helm plugins dir",
|
|
|
|
|
source: "https://github.com/adamreese/helm-env",
|
|
|
|
|
helmPluginsDir: "/foo/bar",
|
|
|
|
|
expectPath: "/foo/bar/helm-env",
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, tt := range tests {
|
|
|
|
|
|
|
|
|
|
t.Setenv("HELM_PLUGINS", tt.helmPluginsDir)
|
|
|
|
|
baseIns := newBase(tt.source)
|
|
|
|
|
baseInsPath := baseIns.Path()
|
|
|
|
|
if baseInsPath != tt.expectPath {
|
|
|
|
|
t.Errorf("expected name %s, got %s", tt.expectPath, baseInsPath)
|
|
|
|
|
}
|
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
|
if tt.helmPluginsDir != "" {
|
|
|
|
|
t.Setenv("HELM_PLUGINS", tt.helmPluginsDir)
|
|
|
|
|
}
|
|
|
|
|
installer := newBase(tt.source)
|
|
|
|
|
path := installer.Path()
|
|
|
|
|
if path != tt.expectPath {
|
|
|
|
|
t.Errorf("expected path %s, got %s", tt.expectPath, path)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|