|
|
@ -24,6 +24,7 @@ import (
|
|
|
|
"github.com/Masterminds/vcs"
|
|
|
|
"github.com/Masterminds/vcs"
|
|
|
|
|
|
|
|
|
|
|
|
"helm.sh/helm/v3/internal/test/ensure"
|
|
|
|
"helm.sh/helm/v3/internal/test/ensure"
|
|
|
|
|
|
|
|
"helm.sh/helm/v3/pkg/cli"
|
|
|
|
"helm.sh/helm/v3/pkg/helmpath"
|
|
|
|
"helm.sh/helm/v3/pkg/helmpath"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -50,6 +51,7 @@ func (r *testRepo) UpdateVersion(version string) error {
|
|
|
|
|
|
|
|
|
|
|
|
func TestVCSInstaller(t *testing.T) {
|
|
|
|
func TestVCSInstaller(t *testing.T) {
|
|
|
|
defer ensure.HelmHome(t)()
|
|
|
|
defer ensure.HelmHome(t)()
|
|
|
|
|
|
|
|
settings := cli.New()
|
|
|
|
|
|
|
|
|
|
|
|
if err := os.MkdirAll(helmpath.DataPath("plugins"), 0755); err != nil {
|
|
|
|
if err := os.MkdirAll(helmpath.DataPath("plugins"), 0755); err != nil {
|
|
|
|
t.Fatalf("Could not create %s: %s", helmpath.DataPath("plugins"), err)
|
|
|
|
t.Fatalf("Could not create %s: %s", helmpath.DataPath("plugins"), err)
|
|
|
@ -62,7 +64,7 @@ func TestVCSInstaller(t *testing.T) {
|
|
|
|
tags: []string{"0.1.0", "0.1.1"},
|
|
|
|
tags: []string{"0.1.0", "0.1.1"},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
i, err := NewForSource(source, "~0.1.0")
|
|
|
|
i, err := NewForSource(source, "~0.1.0", settings.PluginsDirectory)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("unexpected error: %s", err)
|
|
|
|
t.Fatalf("unexpected error: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -94,7 +96,7 @@ func TestVCSInstaller(t *testing.T) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Testing FindSource method, expect error because plugin code is not a cloned repository
|
|
|
|
// Testing FindSource method, expect error because plugin code is not a cloned repository
|
|
|
|
if _, err := FindSource(i.Path()); err == nil {
|
|
|
|
if _, err := FindSource(i.Path(), settings.PluginsDirectory); err == nil {
|
|
|
|
t.Fatalf("expected error for inability to find plugin source, got none")
|
|
|
|
t.Fatalf("expected error for inability to find plugin source, got none")
|
|
|
|
} else if err.Error() != "cannot get information about plugin source" {
|
|
|
|
} else if err.Error() != "cannot get information about plugin source" {
|
|
|
|
t.Fatalf("expected error for inability to find plugin source, got (%v)", err)
|
|
|
|
t.Fatalf("expected error for inability to find plugin source, got (%v)", err)
|
|
|
@ -106,8 +108,9 @@ func TestVCSInstallerNonExistentVersion(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
|
|
source := "https://github.com/adamreese/helm-env"
|
|
|
|
source := "https://github.com/adamreese/helm-env"
|
|
|
|
version := "0.2.0"
|
|
|
|
version := "0.2.0"
|
|
|
|
|
|
|
|
settings := cli.New()
|
|
|
|
|
|
|
|
|
|
|
|
i, err := NewForSource(source, version)
|
|
|
|
i, err := NewForSource(source, version, settings.PluginsDirectory)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("unexpected error: %s", err)
|
|
|
|
t.Fatalf("unexpected error: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -127,8 +130,9 @@ func TestVCSInstallerUpdate(t *testing.T) {
|
|
|
|
defer ensure.HelmHome(t)()
|
|
|
|
defer ensure.HelmHome(t)()
|
|
|
|
|
|
|
|
|
|
|
|
source := "https://github.com/adamreese/helm-env"
|
|
|
|
source := "https://github.com/adamreese/helm-env"
|
|
|
|
|
|
|
|
settings := cli.New()
|
|
|
|
|
|
|
|
|
|
|
|
i, err := NewForSource(source, "")
|
|
|
|
i, err := NewForSource(source, "", settings.PluginsDirectory)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("unexpected error: %s", err)
|
|
|
|
t.Fatalf("unexpected error: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -150,7 +154,7 @@ func TestVCSInstallerUpdate(t *testing.T) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Test FindSource method for positive result
|
|
|
|
// Test FindSource method for positive result
|
|
|
|
pluginInfo, err := FindSource(i.Path())
|
|
|
|
pluginInfo, err := FindSource(i.Path(), settings.PluginsDirectory)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|