From 1f398a59f5db556c53a38edb52d5c6dbaff048b4 Mon Sep 17 00:00:00 2001 From: "Christopher A. Stelma" Date: Fri, 8 Mar 2019 12:14:18 -0800 Subject: [PATCH] more/changed tests Signed-off-by: Christopher A. Stelma --- cmd/helm/installer/init_test.go | 27 ++++++++++++++------------- cmd/helm/repo_add_test.go | 15 +++++++++++++++ 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/cmd/helm/installer/init_test.go b/cmd/helm/installer/init_test.go index dbd8e4e14..40c835895 100644 --- a/cmd/helm/installer/init_test.go +++ b/cmd/helm/installer/init_test.go @@ -18,6 +18,7 @@ package installer // import "k8s.io/helm/cmd/helm/installer" import ( "bytes" + "fmt" "io/ioutil" "os" "testing" @@ -104,28 +105,28 @@ func TestEnsureHome(t *testing.T) { } foundStable := false + stableCachePath := fmt.Sprintf("%s-index.yaml", stableRepository) + foundLocal := false + localCachePath := fmt.Sprintf("%s-index.yaml", LocalRepository) for _, rr := range rf.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 rr.Cache != stableCachePath { + t.Errorf("stable repo cache path is %s, not %s", rr.Cache, stableCachePath) } - if absCache != hh.CacheIndex(stableRepository) { - t.Errorf("%s stable repo cache path doesn't resolve to absolute cache index path", rr.Cache) + foundStable = true + } else if rr.Name == LocalRepository { + if rr.Cache != localCachePath { + t.Errorf("local repo cache path is %s, not %s", rr.Cache, localCachePath) } - break + foundLocal = true } } if !foundStable { t.Errorf("stable repo not found") } + if !foundLocal { + t.Errorf("local repo not found") + } expectedDirs := []string{hh.String(), hh.Repository(), hh.Cache(), hh.LocalRepository()} for _, dir := range expectedDirs { diff --git a/cmd/helm/repo_add_test.go b/cmd/helm/repo_add_test.go index 5a458cef7..a11557787 100644 --- a/cmd/helm/repo_add_test.go +++ b/cmd/helm/repo_add_test.go @@ -17,6 +17,7 @@ limitations under the License. package main import ( + "fmt" "io" "os" "testing" @@ -89,6 +90,20 @@ func TestRepoAdd(t *testing.T) { t.Error(err) } + foundTestRepo := false + repoCachePath := fmt.Sprintf("%s-index.yaml", testName) + for _, rr := range f.Repositories { + if rr.Name == testName { + if rr.Cache != repoCachePath { + t.Errorf("%s repo cache path is %s, not %s", testName, rr.Cache, repoCachePath) + } + foundTestRepo = true + } + } + if !foundTestRepo { + t.Errorf("%s repo not found", testName) + } + if !f.Has(testName) { t.Errorf("%s was not successfully inserted into %s", testName, hh.RepositoryFile()) }