From 1042019541f0c93b170ef70b84ebe8a330299a07 Mon Sep 17 00:00:00 2001 From: "seanson@users.noreply.github.com" Date: Mon, 17 Feb 2020 10:50:18 +1100 Subject: [PATCH] fix: Add testcase for issue #238 --- charts/argo-cd/test/helm_test.go | 76 ++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/charts/argo-cd/test/helm_test.go b/charts/argo-cd/test/helm_test.go index 0e1d9cc9..504637c0 100644 --- a/charts/argo-cd/test/helm_test.go +++ b/charts/argo-cd/test/helm_test.go @@ -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") + }) + } +}