diff --git a/ct/cmd/install.go b/ct/cmd/install.go index 4afeb8186..6a79016d3 100644 --- a/ct/cmd/install.go +++ b/ct/cmd/install.go @@ -98,7 +98,7 @@ func install(cmd *cobra.Command, _ []string) error { testing, err := chart.NewTesting(*configuration) if err != nil { - fmt.Println(err) + return err } results, err := testing.InstallCharts() testing.PrintResults(results) diff --git a/ct/cmd/install_test.go b/ct/cmd/install_test.go new file mode 100644 index 000000000..b7b118907 --- /dev/null +++ b/ct/cmd/install_test.go @@ -0,0 +1,35 @@ +// Copyright The Helm Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package cmd + +import ( + "errors" + "os/exec" + "testing" +) + +func TestInstallReturnsHelmLookupError(t *testing.T) { + t.Setenv("PATH", "") + t.Setenv("CT_CONFIG_DIR", "install-test-no-config") + + cmd := NewRootCmd() + cmd.SetArgs([]string{"install", "--all", "--chart-dirs="}) + err := cmd.Execute() + + var lookupErr *exec.Error + if !errors.As(err, &lookupErr) || lookupErr.Name != "helm" || !errors.Is(err, exec.ErrNotFound) { + t.Fatalf("ct install returned %v, want a Helm executable lookup error", err) + } +}