From c4f91cb949f3446bb9e740055617cf1ebb937e49 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 781939800..3b547ea1f 100644 --- a/cmd/helm/init_test.go +++ b/cmd/helm/init_test.go @@ -22,6 +22,7 @@ import ( "testing" "k8s.io/helm/pkg/helm/helmpath" + "k8s.io/helm/pkg/repo" ) func TestEnsureHome(t *testing.T) { @@ -42,6 +43,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()} for _, dir := range expectedDirs { if fi, err := os.Stat(dir); err != nil {