Initialize run.Configs in the NewSTEP functions [#67]
This fixes the run package's leaky abstraction; other packages no longer need to know or care that run.Config even exists. Note that since the various Steps now depend on having a non-nil pointer to a run.Config, it's unsafe (or at least risky) to initialize them directly. They should be created with their NewSTEPNAME functions. All their fields are now private, to reflect this.
This commit is contained in:
35
internal/run/config_test.go
Normal file
35
internal/run/config_test.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package run
|
||||
|
||||
import (
|
||||
"github.com/pelotech/drone-helm3/internal/env"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type ConfigTestSuite struct {
|
||||
suite.Suite
|
||||
}
|
||||
|
||||
func TestConfigTestSuite(t *testing.T) {
|
||||
suite.Run(t, new(ConfigTestSuite))
|
||||
}
|
||||
|
||||
func (suite *ConfigTestSuite) TestNewConfig() {
|
||||
stdout := &strings.Builder{}
|
||||
stderr := &strings.Builder{}
|
||||
envCfg := env.Config{
|
||||
Namespace: "private",
|
||||
Debug: true,
|
||||
Stdout: stdout,
|
||||
Stderr: stderr,
|
||||
}
|
||||
cfg := newConfig(envCfg)
|
||||
suite.Require().NotNil(cfg)
|
||||
suite.Equal(&config{
|
||||
namespace: "private",
|
||||
debug: true,
|
||||
stdout: stdout,
|
||||
stderr: stderr,
|
||||
}, cfg)
|
||||
}
|
||||
Reference in New Issue
Block a user