From b93917c857d83eb4b5d580be3d943b1dbd83edd8 Mon Sep 17 00:00:00 2001 From: Erin Call Date: Thu, 19 Dec 2019 10:21:11 -0800 Subject: [PATCH] Use better expectations in lint_test [#3] The tests need to allow calls to Stdout/Stderr so they don't get "Unexpected call" errors from gomock, but these tests aren't meant to assert that the calls actually happened. Using .AnyTimes allows 0 or more calls. --- internal/run/lint_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/run/lint_test.go b/internal/run/lint_test.go index b3881bd..feb6d5f 100644 --- a/internal/run/lint_test.go +++ b/internal/run/lint_test.go @@ -61,8 +61,8 @@ func (suite *LintTestSuite) TestPrepareAndExecute() { 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()) + suite.mockCmd.EXPECT().Stdout(gomock.Any()).AnyTimes() + suite.mockCmd.EXPECT().Stderr(gomock.Any()).AnyTimes() cfg := Config{} l := Lint{} @@ -96,8 +96,8 @@ func (suite *LintTestSuite) TestPrepareWithLintFlags() { return suite.mockCmd } - suite.mockCmd.EXPECT().Stdout(gomock.Any()) - suite.mockCmd.EXPECT().Stderr(gomock.Any()) + suite.mockCmd.EXPECT().Stdout(gomock.Any()).AnyTimes() + suite.mockCmd.EXPECT().Stderr(gomock.Any()).AnyTimes() err := l.Prepare(cfg) suite.Require().Nil(err) @@ -126,7 +126,7 @@ func (suite *LintTestSuite) TestPrepareWithDebugFlag() { } suite.mockCmd.EXPECT().Stdout(gomock.Any()) - suite.mockCmd.EXPECT().Stderr(gomock.Any()) + suite.mockCmd.EXPECT().Stderr(&stderr) err := l.Prepare(cfg) suite.Require().Nil(err) @@ -152,8 +152,8 @@ func (suite *LintTestSuite) TestPrepareWithNamespaceFlag() { return suite.mockCmd } - suite.mockCmd.EXPECT().Stdout(gomock.Any()) - suite.mockCmd.EXPECT().Stderr(gomock.Any()) + suite.mockCmd.EXPECT().Stdout(gomock.Any()).AnyTimes() + suite.mockCmd.EXPECT().Stderr(gomock.Any()).AnyTimes() err := l.Prepare(cfg) suite.Require().Nil(err)