Skip to content

Commit

Permalink
Add unittest for env
Browse files Browse the repository at this point in the history
Signed-off-by: mehabhalodiya <mehabhalodiya@gmail.com>
  • Loading branch information
mehabhalodiya committed Feb 16, 2024
1 parent 20dd48b commit bf325ad
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions controllers/argocd/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit bf325ad

Please sign in to comment.