From 3668cc251b172ae53223263f16e470591294ecda Mon Sep 17 00:00:00 2001 From: "seanson@users.noreply.github.com" Date: Mon, 9 Mar 2020 21:36:39 +1100 Subject: [PATCH] Add test case for #257 --- charts/argo-cd/Chart.yaml | 2 +- charts/argo-cd/test/helm_test.go | 79 ++++++++++++++++++++++++++++++-- 2 files changed, 76 insertions(+), 5 deletions(-) diff --git a/charts/argo-cd/Chart.yaml b/charts/argo-cd/Chart.yaml index 04a5fb87..dcd05a27 100644 --- a/charts/argo-cd/Chart.yaml +++ b/charts/argo-cd/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v1 appVersion: "1.4.2" description: A Helm chart for ArgoCD, a declarative, GitOps continuous delivery tool for Kubernetes. name: argo-cd -version: 1.8.7 +version: 1.8.8 home: https://github.com/argoproj/argo-helm icon: https://raw.githubusercontent.com/argoproj/argo/master/docs/assets/argo.png keywords: diff --git a/charts/argo-cd/test/helm_test.go b/charts/argo-cd/test/helm_test.go index c3805cb8..a9b480cd 100644 --- a/charts/argo-cd/test/helm_test.go +++ b/charts/argo-cd/test/helm_test.go @@ -506,9 +506,9 @@ func TestArgoCDVolumeMounts(t *testing.T) { }, } - var deployment appsv1.Deployment - for _, test := range tests { + var deployment appsv1.Deployment + options := &helm.Options{ SetValues: test.SetValues, KubectlOptions: k8s.NewKubectlOptions("", "", "default"), @@ -589,9 +589,9 @@ func TestArgoCDVolumes(t *testing.T) { }, } - var deployment appsv1.Deployment - for _, test := range tests { + var deployment appsv1.Deployment + options := &helm.Options{ SetValues: test.SetValues, KubectlOptions: k8s.NewKubectlOptions("", "", "default"), @@ -605,3 +605,74 @@ func TestArgoCDVolumes(t *testing.T) { }) } } + +// https://github.com/argoproj/argo-helm/issues/238 +func TestArgoCDLabelAnnotations(t *testing.T) { + t.Parallel() + helmChartPath, err := filepath.Abs("../") + releaseName := "argo-cd" + require.NoError(t, err) + 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.podLabels.testLabel": "testLabel", + "controller.podAnnotation.testAnnotation": "testAnnotate", + }, + }, + { + Name: "Given volumeMount and a reposerver deployment", + DeploymentYAML: []string{"templates/argocd-repo-server/deployment.yaml"}, + SetValues: map[string]string{ + "repoServer.podLabels.testLabel": "testLabel", + "repoServer.podAnnotation.testAnnotation": "testAnnotate", + }, + }, + { + Name: "Given volumeMount and a server deployment", + DeploymentYAML: []string{"templates/argocd-server/deployment.yaml"}, + SetValues: map[string]string{ + "server.podLabels.testLabel": "testLabel", + "server.podAnnotation.testAnnotation": "testAnnotate", + }, + }, + { + Name: "Given volumeMount and a dex deployment", + DeploymentYAML: []string{"templates/dex/deployment.yaml"}, + SetValues: map[string]string{ + "dex.podLabels.testLabel": "testLabel", + "dex.podAnnotation.testAnnotation": "testAnnotate", + }, + }, + { + Name: "Given a volumeMount and a redis deployment", + DeploymentYAML: []string{"templates/redis/deployment.yaml"}, + SetValues: map[string]string{ + "redis.podLabels.testLabel": "testLabel", + "redis.podAnnotation.testAnnotation": "testAnnotate", + }, + }, + } + + for _, test := range tests { + var deployment appsv1.Deployment + + 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) + + So(deployment.Spec.Template.ObjectMeta.Labels["testLabel"], ShouldEqual, "testLabel") + // So(deploymentContainers[0].VolumeMounts[0].Name, ShouldEqual, "test") + }) + } +}