Extract the debug/namespace flags into run.Config [#67]

This is a general-purpose cleanup commit; every step except InitKube had
the same six "add the --debug and --namespace flags if applicable" code.
This commit is contained in:
Erin Call
2020-01-17 11:12:53 -08:00
parent a21848484b
commit 79532e7635
13 changed files with 31 additions and 258 deletions

View File

@@ -1,7 +1,6 @@
package run
import (
"fmt"
"github.com/golang/mock/gomock"
"github.com/pelotech/drone-helm3/internal/env"
"github.com/stretchr/testify/assert"
@@ -75,20 +74,3 @@ func (suite *HelpTestSuite) TestExecute() {
help.helmCommand = "get down on friday"
suite.EqualError(help.Execute(), "unknown command 'get down on friday'")
}
func (suite *HelpTestSuite) TestPrepareDebugFlag() {
stdout := strings.Builder{}
stderr := strings.Builder{}
cfg := env.Config{
Debug: true,
Stdout: &stdout,
Stderr: &stderr,
}
help := NewHelp(cfg)
help.Prepare()
want := fmt.Sprintf("Generated command: '%s --debug help'\n", helmBin)
suite.Equal(want, stderr.String())
suite.Equal("", stdout.String())
}