Initialize Steps with a NewSTEPNAME function [#67]
This seems to be be a more natural separation of concerns--the knowledge of which config fields map to which parts of a Step belong to the Step, not to the Plan.
This commit is contained in:
@@ -130,46 +130,10 @@ func (suite *PlanTestSuite) TestExecuteAbortsOnError() {
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestUpgrade() {
|
||||
cfg := env.Config{
|
||||
ChartVersion: "seventeen",
|
||||
DryRun: true,
|
||||
Wait: true,
|
||||
Values: "steadfastness,forthrightness",
|
||||
StringValues: "tensile_strength,flexibility",
|
||||
ValuesFiles: []string{"/root/price_inventory.yml"},
|
||||
ReuseValues: true,
|
||||
Timeout: "go sit in the corner",
|
||||
Chart: "billboard_top_100",
|
||||
Release: "post_malone_circles",
|
||||
Force: true,
|
||||
AtomicUpgrade: true,
|
||||
CleanupOnFail: true,
|
||||
}
|
||||
|
||||
steps := upgrade(cfg)
|
||||
steps := upgrade(env.Config{})
|
||||
suite.Require().Equal(2, len(steps), "upgrade should return 2 steps")
|
||||
suite.Require().IsType(&run.InitKube{}, steps[0])
|
||||
|
||||
suite.Require().IsType(&run.Upgrade{}, steps[1])
|
||||
upgrade, _ := steps[1].(*run.Upgrade)
|
||||
|
||||
expected := &run.Upgrade{
|
||||
Chart: cfg.Chart,
|
||||
Release: cfg.Release,
|
||||
ChartVersion: cfg.ChartVersion,
|
||||
DryRun: true,
|
||||
Wait: cfg.Wait,
|
||||
Values: "steadfastness,forthrightness",
|
||||
StringValues: "tensile_strength,flexibility",
|
||||
ValuesFiles: []string{"/root/price_inventory.yml"},
|
||||
ReuseValues: cfg.ReuseValues,
|
||||
Timeout: cfg.Timeout,
|
||||
Force: cfg.Force,
|
||||
Atomic: true,
|
||||
CleanupOnFail: true,
|
||||
}
|
||||
|
||||
suite.Equal(expected, upgrade)
|
||||
suite.IsType(&run.InitKube{}, steps[0])
|
||||
suite.IsType(&run.Upgrade{}, steps[1])
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestUpgradeWithUpdateDependencies() {
|
||||
@@ -194,43 +158,11 @@ func (suite *PlanTestSuite) TestUpgradeWithAddRepos() {
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestUninstall() {
|
||||
cfg := env.Config{
|
||||
KubeToken: "b2YgbXkgYWZmZWN0aW9u",
|
||||
SkipTLSVerify: true,
|
||||
Certificate: "cHJvY2xhaW1zIHdvbmRlcmZ1bCBmcmllbmRzaGlw",
|
||||
APIServer: "98.765.43.21",
|
||||
ServiceAccount: "greathelm",
|
||||
DryRun: true,
|
||||
Timeout: "think about what you did",
|
||||
Release: "jetta_id_love_to_change_the_world",
|
||||
KeepHistory: true,
|
||||
}
|
||||
|
||||
steps := uninstall(cfg)
|
||||
steps := uninstall(env.Config{})
|
||||
suite.Require().Equal(2, len(steps), "uninstall should return 2 steps")
|
||||
|
||||
suite.Require().IsType(&run.InitKube{}, steps[0])
|
||||
init, _ := steps[0].(*run.InitKube)
|
||||
var expected Step = &run.InitKube{
|
||||
SkipTLSVerify: true,
|
||||
Certificate: "cHJvY2xhaW1zIHdvbmRlcmZ1bCBmcmllbmRzaGlw",
|
||||
APIServer: "98.765.43.21",
|
||||
ServiceAccount: "greathelm",
|
||||
Token: "b2YgbXkgYWZmZWN0aW9u",
|
||||
TemplateFile: kubeConfigTemplate,
|
||||
ConfigFile: kubeConfigFile,
|
||||
}
|
||||
|
||||
suite.Equal(expected, init)
|
||||
|
||||
suite.Require().IsType(&run.Uninstall{}, steps[1])
|
||||
actual, _ := steps[1].(*run.Uninstall)
|
||||
expected = &run.Uninstall{
|
||||
Release: "jetta_id_love_to_change_the_world",
|
||||
DryRun: true,
|
||||
KeepHistory: true,
|
||||
}
|
||||
suite.Equal(expected, actual)
|
||||
suite.IsType(&run.InitKube{}, steps[0])
|
||||
suite.IsType(&run.Uninstall{}, steps[1])
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestUninstallWithUpdateDependencies() {
|
||||
@@ -244,46 +176,21 @@ func (suite *PlanTestSuite) TestUninstallWithUpdateDependencies() {
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestInitKube() {
|
||||
cfg := env.Config{
|
||||
KubeToken: "cXVlZXIgY2hhcmFjdGVyCg==",
|
||||
SkipTLSVerify: true,
|
||||
Certificate: "b2Ygd29rZW5lc3MK",
|
||||
APIServer: "123.456.78.9",
|
||||
ServiceAccount: "helmet",
|
||||
}
|
||||
cfg := env.Config{}
|
||||
|
||||
steps := initKube(cfg)
|
||||
suite.Require().Equal(1, len(steps), "initKube should return one step")
|
||||
suite.Require().IsType(&run.InitKube{}, steps[0])
|
||||
init, _ := steps[0].(*run.InitKube)
|
||||
|
||||
expected := &run.InitKube{
|
||||
SkipTLSVerify: true,
|
||||
Certificate: "b2Ygd29rZW5lc3MK",
|
||||
APIServer: "123.456.78.9",
|
||||
ServiceAccount: "helmet",
|
||||
Token: "cXVlZXIgY2hhcmFjdGVyCg==",
|
||||
TemplateFile: kubeConfigTemplate,
|
||||
ConfigFile: kubeConfigFile,
|
||||
}
|
||||
suite.Equal(expected, init)
|
||||
suite.IsType(&run.InitKube{}, steps[0])
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestDepUpdate() {
|
||||
cfg := env.Config{
|
||||
UpdateDependencies: true,
|
||||
Chart: "scatterplot",
|
||||
}
|
||||
|
||||
steps := depUpdate(cfg)
|
||||
suite.Require().Equal(1, len(steps), "depUpdate should return one step")
|
||||
suite.Require().IsType(&run.DepUpdate{}, steps[0])
|
||||
update, _ := steps[0].(*run.DepUpdate)
|
||||
|
||||
expected := &run.DepUpdate{
|
||||
Chart: "scatterplot",
|
||||
}
|
||||
suite.Equal(expected, update)
|
||||
suite.IsType(&run.DepUpdate{}, steps[0])
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestAddRepos() {
|
||||
@@ -295,35 +202,14 @@ func (suite *PlanTestSuite) TestAddRepos() {
|
||||
}
|
||||
steps := addRepos(cfg)
|
||||
suite.Require().Equal(2, len(steps), "addRepos should add one step per repo")
|
||||
suite.Require().IsType(&run.AddRepo{}, steps[0])
|
||||
suite.Require().IsType(&run.AddRepo{}, steps[1])
|
||||
first := steps[0].(*run.AddRepo)
|
||||
second := steps[1].(*run.AddRepo)
|
||||
|
||||
suite.Equal(first.Repo, "first=https://add.repos/one")
|
||||
suite.Equal(second.Repo, "second=https://add.repos/two")
|
||||
suite.IsType(&run.AddRepo{}, steps[0])
|
||||
suite.IsType(&run.AddRepo{}, steps[1])
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestLint() {
|
||||
cfg := env.Config{
|
||||
Chart: "./flow",
|
||||
Values: "steadfastness,forthrightness",
|
||||
StringValues: "tensile_strength,flexibility",
|
||||
ValuesFiles: []string{"/root/price_inventory.yml"},
|
||||
LintStrictly: true,
|
||||
}
|
||||
|
||||
steps := lint(cfg)
|
||||
suite.Equal(1, len(steps))
|
||||
|
||||
want := &run.Lint{
|
||||
Chart: "./flow",
|
||||
Values: "steadfastness,forthrightness",
|
||||
StringValues: "tensile_strength,flexibility",
|
||||
ValuesFiles: []string{"/root/price_inventory.yml"},
|
||||
Strict: true,
|
||||
}
|
||||
suite.Equal(want, steps[0])
|
||||
steps := lint(env.Config{})
|
||||
suite.Require().Equal(1, len(steps))
|
||||
suite.IsType(&run.Lint{}, steps[0])
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestLintWithUpdateDependencies() {
|
||||
|
||||
Reference in New Issue
Block a user