From 0528c7bb19daec796167d3a9705b2ac20543e8bd Mon Sep 17 00:00:00 2001 From: Torsten Walter Date: Mon, 3 Jun 2019 12:43:00 +0200 Subject: [PATCH] add test for output-dir Signed-off-by: Torsten Walter --- pkg/action/install_test.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/pkg/action/install_test.go b/pkg/action/install_test.go index 063be75a0..12f9bb3b2 100644 --- a/pkg/action/install_test.go +++ b/pkg/action/install_test.go @@ -18,6 +18,10 @@ package action import ( "fmt" + "io/ioutil" + "log" + "os" + "path/filepath" "reflect" "regexp" "testing" @@ -354,3 +358,34 @@ func TestMergeValues(t *testing.T) { t.Errorf("Expected a map with different keys to merge properly with another map. Expected: %v, got %v", expectedMap, testMap) } } + +func TestInstallReleaseOutputDir(t *testing.T) { + is := assert.New(t) + instAction := installAction(t) + instAction.rawValues = map[string]interface{}{} + + dir, err := ioutil.TempDir("", "output-dir") + if err != nil { + log.Fatal(err) + } + defer os.RemoveAll(dir) + + instAction.OutputDir = dir + + _, err = instAction.Run(buildChart(withSampleTemplates())) + if err != nil { + t.Fatalf("Failed install: %s", err) + } + + _, err = os.Stat(filepath.Join(dir, "hello/templates/goodbye")) + is.NoError(err) + + _, err = os.Stat(filepath.Join(dir, "hello/templates/hello")) + is.NoError(err) + + _, err = os.Stat(filepath.Join(dir, "hello/templates/with-partials")) + is.NoError(err) + + _, err = os.Stat(filepath.Join(dir, "hello/templates/empty")) + is.True(os.IsNotExist(err)) +}