Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[charts/argo-cd] Initial testing tests for validating Helm chart outputs # #183

Closed
wants to merge 6 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: Add testcase for issue #238
  • Loading branch information
seanson committed Mar 9, 2020
commit 1042019541f0c93b170ef70b84ebe8a330299a07
76 changes: 76 additions & 0 deletions charts/argo-cd/test/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,3 +444,79 @@ func TestArgoCDExtraArgs(t *testing.T) {
})
}
}

// https://github.com/argoproj/argo-helm/issues/238
func TestArgoCDVolumeMounts(t *testing.T) {
t.Parallel()
helmChartPath, err := filepath.Abs("../")
releaseName := "argo-cd"
require.NoError(t, err)
// server:
// volumeMounts:
// - mountPath: /test
// name: test
tests := []struct {
Name string
DeploymentYAML []string
SetValues map[string]string
SetStrValues map[string]string
}{
{
Name: "Given volumeMount and an application controller deployment",
DeploymentYAML: []string{"templates/argocd-application-controller/deployment.yaml"},
SetValues: map[string]string{
"controller.volumeMounts[0].mountPath": "/test",
"controller.volumeMounts[0].name": "test",
},
},
{
Name: "Given volumeMount and a reposerver deployment",
DeploymentYAML: []string{"templates/argocd-repo-server/deployment.yaml"},
SetValues: map[string]string{
"repoServer.volumeMounts[0].mountPath": "/test",
"repoServer.volumeMounts[0].name": "test",
},
},
{
Name: "Given volumeMount and a server deployment",
DeploymentYAML: []string{"templates/argocd-server/deployment.yaml"},
SetValues: map[string]string{
"server.volumeMounts[0].mountPath": "/test",
"server.volumeMounts[0].name": "test",
},
},
{
Name: "Given volumeMount and a dex deployment",
DeploymentYAML: []string{"templates/argocd-server/deployment.yaml"},
SetValues: map[string]string{
"server.volumeMounts[1].mountPath": "/test",
"server.volumeMounts[1].name": "test",
},
},
{
Name: "Given a volumeMount and a redis deployment",
DeploymentYAML: []string{"templates/redis/deployment.yaml"},
SetValues: map[string]string{
"redis.volumeMounts[0].mountPath": "/test",
"redis.volumeMounts[0].name": "test",
},
},
}

var deployment appsv1.Deployment

for _, test := range tests {
options := &helm.Options{
SetValues: test.SetValues,
KubectlOptions: k8s.NewKubectlOptions("", "", "default"),
}
Convey(test.Name, t, func() {
output := helm.RenderTemplate(t, options, helmChartPath, releaseName, test.DeploymentYAML)
helm.UnmarshalK8SYaml(t, output, &deployment)
deploymentContainers := deployment.Spec.Template.Spec.Containers
So(len(deploymentContainers[0].VolumeMounts), ShouldBeGreaterThanOrEqualTo, 1)
So(deploymentContainers[0].VolumeMounts[0].MountPath, ShouldEqual, "/test")
So(deploymentContainers[0].VolumeMounts[0].Name, ShouldEqual, "test")
})
}
}