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.
This commit is contained in:
Erin Call 2019-12-19 10:21:11 -08:00
parent 84ac019838
commit b93917c857
No known key found for this signature in database
GPG key ID: 4071FF6C15B8DAD1

View file

@ -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)