From d357b0d0d0a77efe283a6d3a08b30a970b6d5359 Mon Sep 17 00:00:00 2001 From: "Christopher A. Stelma" Date: Wed, 7 Nov 2018 17:21:49 -0800 Subject: [PATCH] tests --- cmd/helm/init_test.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/cmd/helm/init_test.go b/cmd/helm/init_test.go index fd6ef97c4..7c9deb044 100644 --- a/cmd/helm/init_test.go +++ b/cmd/helm/init_test.go @@ -39,6 +39,7 @@ import ( "k8s.io/helm/cmd/helm/installer" "k8s.io/helm/pkg/helm/helmpath" + "k8s.io/helm/pkg/repo" ) func TestInitCmd(t *testing.T) { @@ -202,6 +203,35 @@ func TestEnsureHome(t *testing.T) { t.Error(err) } + rr, err := repo.LoadRepositoriesFile(hh.RepositoryFile()) + if err != nil { + t.Error(err) + } + + foundStable := false + for _, rr := range rr.Repositories { + if rr.Name == stableRepository { + foundStable = true + if err != nil { + t.Error(err) + } + if !filepath.IsAbs(rr.Cache) { + t.Errorf("%s stable repo cache path is an absolute path", rr.Cache) + } + absCache, err := filepath.Abs(filepath.Join(hh.Cache(), rr.Cache)) + if err != nil { + t.Error(err) + } + if absCache != hh.CacheIndex(stableRepository) { + t.Errorf("%s stable repo cache path doesn't resolve to absolute cache index path", rr.Cache) + } + break + } + } + if !foundStable { + t.Errorf("stable repo not found") + } + expectedDirs := []string{hh.String(), hh.Repository(), hh.Cache(), hh.LocalRepository()} for _, dir := range expectedDirs { if fi, err := os.Stat(dir); err != nil {