Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

Commit

Permalink
add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
dexhorthy committed Mar 24, 2019
1 parent 3af4b56 commit 4c63822
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions pkg/lifecycle/daemon/routes_navcycle_getstep_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,84 @@ func TestHydrateStep(t *testing.T) {
},
},
},
{
name: "helm values readme",
step: api.Step{
HelmValues: &api.HelmValues{
StepShared: api.StepShared{
ID: "bar",
},
Path: "consul/values.yaml",
Readme: &api.HelmValuesReadmeSource{
Contents: "## the-readme",
},
},
},
release: &api.Release{
Metadata: api.ReleaseMetadata{
CustomerID: "12345",
},
Spec: api.Spec{},
},
state: state2.VersionedState{
V1: &state2.V1{
HelmValues: "fake: values",
ReleaseName: "fake-releasename",
Namespace: "fake-namespace",
HelmValuesDefaults: "fake: defaults",
},
},
fs: map[string]string{
"consul/values.yaml": "fake: values-fs",
},
want: &daemontypes.StepResponse{
CurrentStep: daemontypes.Step{
Source: api.Step{
HelmValues: &api.HelmValues{
StepShared: api.StepShared{
ID: "bar",
},
Path: "consul/values.yaml",

Readme: &api.HelmValuesReadmeSource{
Contents: "## the-readme",
},
},
},
HelmValues: &daemontypes.HelmValues{
Values: "fake: values\n",
DefaultValues: "fake: values-fs",
ReleaseName: "fake-releasename",
Namespace: "fake-namespace",
Path: "consul/values.yaml",
Readme: "## the-readme",
},
},
Phase: "helm-values",
Actions: []daemontypes.Action{
{
ButtonType: "primary",
Text: "Saving",
LoadingText: "Save",
OnClick: daemontypes.ActionRequest{
URI: fmt.Sprintf("/helm-values"),
Method: "POST",
Body: "",
},
},
{
ButtonType: "popover",
Text: "Save & Continue",
LoadingText: "Saving",
OnClick: daemontypes.ActionRequest{
URI: fmt.Sprintf("/navcycle/step/%s", "bar"),
Method: "POST",
Body: "",
},
},
},
},
},
}

for _, test := range tests {
Expand All @@ -490,6 +568,11 @@ func TestHydrateStep(t *testing.T) {
mockState.EXPECT().TryLoad().Return(test.state, nil)
}

for fn, file := range test.fs {
err := mockFs.WriteFile(fn, []byte(file), 0644)
req.NoError(err)
}

v2 := &NavcycleRoutes{
BuilderBuilder: templates.NewBuilderBuilder(
testLogger,
Expand Down

0 comments on commit 4c63822

Please sign in to comment.