Skip to content

Commit

Permalink
testing: setup a temp HelmHome for a few tests
Browse files Browse the repository at this point in the history
these tests will dirty the HelmHome

Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
  • Loading branch information
zhijianli88 committed Sep 30, 2020
1 parent 733b3a1 commit 2a06251
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/helm/dependency_build_test.go
Expand Up @@ -22,12 +22,14 @@ import (
"strings"
"testing"

"helm.sh/helm/v3/internal/test/ensure"
"helm.sh/helm/v3/pkg/provenance"
"helm.sh/helm/v3/pkg/repo"
"helm.sh/helm/v3/pkg/repo/repotest"
)

func TestDependencyBuildCmd(t *testing.T) {
ensure.HelmHome(t)
srv, err := repotest.NewTempServerWithCleanup(t, "testdata/testcharts/*.tgz")
defer srv.Stop()
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions cmd/helm/dependency_update_test.go
Expand Up @@ -33,6 +33,7 @@ import (
)

func TestDependencyUpdateCmd(t *testing.T) {
ensure.HelmHome(t)
srv, err := repotest.NewTempServerWithCleanup(t, "testdata/testcharts/*.tgz")
if err != nil {
t.Fatal(err)
Expand Down
2 changes: 2 additions & 0 deletions cmd/helm/pull_test.go
Expand Up @@ -22,10 +22,12 @@ import (
"path/filepath"
"testing"

"helm.sh/helm/v3/internal/test/ensure"
"helm.sh/helm/v3/pkg/repo/repotest"
)

func TestPullCmd(t *testing.T) {
ensure.HelmHome(t)
srv, err := repotest.NewTempServerWithCleanup(t, "testdata/testcharts/*.tgz*")
if err != nil {
t.Fatal(err)
Expand Down
1 change: 1 addition & 0 deletions cmd/helm/repo_add_test.go
Expand Up @@ -143,6 +143,7 @@ func TestRepoAddConcurrentDirNotExist(t *testing.T) {
}

func repoAddConcurrent(t *testing.T, testName, repoFile string) {
ensure.HelmHome(t)
ts, err := repotest.NewTempServerWithCleanup(t, "testdata/testserver/*.*")
if err != nil {
t.Fatal(err)
Expand Down
1 change: 1 addition & 0 deletions cmd/helm/repo_remove_test.go
Expand Up @@ -30,6 +30,7 @@ import (
)

func TestRepoRemove(t *testing.T) {
ensure.HelmHome(t)
ts, err := repotest.NewTempServerWithCleanup(t, "testdata/testserver/*.*")
if err != nil {
t.Fatal(err)
Expand Down
3 changes: 3 additions & 0 deletions pkg/downloader/manager_test.go
Expand Up @@ -21,6 +21,7 @@ import (
"reflect"
"testing"

"helm.sh/helm/v3/internal/test/ensure"
"helm.sh/helm/v3/pkg/chart"
"helm.sh/helm/v3/pkg/chartutil"
"helm.sh/helm/v3/pkg/getter"
Expand Down Expand Up @@ -182,6 +183,7 @@ func TestGetRepoNames(t *testing.T) {
}

func TestUpdateBeforeBuild(t *testing.T) {
ensure.HelmHome(t)
// Set up a fake repo
srv, err := repotest.NewTempServerWithCleanup(t, "testdata/*.tgz*")
if err != nil {
Expand Down Expand Up @@ -256,6 +258,7 @@ func TestUpdateBeforeBuild(t *testing.T) {
// Parent chart includes local-subchart 0.1.0 subchart from a fake repository, by default.
// If each of these main fields (name, version, repository) is not supplied by dep param, default value will be used.
func checkBuildWithOptionalFields(t *testing.T, chartName string, dep chart.Dependency) {
ensure.HelmHome(t)
// Set up a fake repo
srv, err := repotest.NewTempServerWithCleanup(t, "testdata/*.tgz*")
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions pkg/plugin/installer/local_installer_test.go
Expand Up @@ -21,12 +21,14 @@ import (
"path/filepath"
"testing"

"helm.sh/helm/v3/internal/test/ensure"
"helm.sh/helm/v3/pkg/helmpath"
)

var _ Installer = new(LocalInstaller)

func TestLocalInstaller(t *testing.T) {
ensure.HelmHome(t)
// Make a temp dir
tdir, err := ioutil.TempDir("", "helm-installer-")
if err != nil {
Expand Down

0 comments on commit 2a06251

Please sign in to comment.