diff --git a/controllers/argocd/util_test.go b/controllers/argocd/util_test.go index c06812dcd..5c1619ba9 100644 --- a/controllers/argocd/util_test.go +++ b/controllers/argocd/util_test.go @@ -30,6 +30,12 @@ const ( redisHAProxyTestImage = "testing/redis-ha-haproxy:latest-ha" ) +func setEnv(e []v1.EnvVar) argoCDOpt { + return func(a *argoproj.ArgoCD) { + a.Spec.Controller.Env = e + } +} + var imageTests = []struct { name string pre func(t *testing.T) @@ -542,6 +548,33 @@ func TestGetArgoApplicationControllerCommand(t *testing.T) { } } +func TestGetArgoApplicationEnv(t *testing.T) { + + validEnv := []v1.EnvVar{ + v1.EnvVar{Name: "HOME", Value: "/home/argocd", ValueFrom: (*v1.EnvVarSource)(nil)}} + + cmdTests := []struct { + name string + opts []argoCDOpt + want []v1.EnvVar + }{ + { + "configured setenv to test", + []argoCDOpt{setEnv(validEnv)}, + validEnv, + }, + } + + for _, tt := range cmdTests { + cr := makeTestArgoCD(tt.opts...) + env := getArgoControllerContainerEnv(cr) + + if !reflect.DeepEqual(env, tt.want) { + t.Fatalf("got %#v, want %#v", env, tt.want) + } + } +} + func TestDeleteRBACsForNamespace(t *testing.T) { a := makeTestArgoCD() testClient := testclient.NewSimpleClientset()