From a6a2d6e6a342851f2cc962dbe8805efa0666218d Mon Sep 17 00:00:00 2001 From: Erin Call Date: Tue, 17 Dec 2019 17:00:34 -0800 Subject: [PATCH] Require a nonempty chart in Lint.Prepare [#3] --- internal/run/lint.go | 4 ++++ internal/run/lint_test.go | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/internal/run/lint.go b/internal/run/lint.go index bdc4f8c..aa18128 100644 --- a/internal/run/lint.go +++ b/internal/run/lint.go @@ -18,6 +18,10 @@ func (l *Lint) Execute(_ Config) error { // Prepare gets the Lint ready to execute. func (l *Lint) Prepare(cfg Config) error { + if l.Chart == "" { + return fmt.Errorf("chart is required") + } + args := make([]string, 0) if cfg.Debug { diff --git a/internal/run/lint_test.go b/internal/run/lint_test.go index 25a6f26..9f88598 100644 --- a/internal/run/lint_test.go +++ b/internal/run/lint_test.go @@ -59,6 +59,18 @@ func (suite *LintTestSuite) TestPrepareAndExecute() { l.Execute(cfg) } +func (suite *LintTestSuite) TestPrepareRequiresChart() { + // These aren't really expected, but allowing them gives clearer test-failure messages + suite.mockCmd.EXPECT().Stdout(gomock.Any()) + suite.mockCmd.EXPECT().Stderr(gomock.Any()) + + cfg := Config{} + l := Lint{} + + err := l.Prepare(cfg) + suite.EqualError(err, "chart is required", "Chart should be mandatory") +} + func (suite *LintTestSuite) TestPrepareWithLintFlags() { defer suite.ctrl.Finish()