@@ -2241,6 +2241,56 @@ var _ = Describe("newArgoCD", func() {
22412241 Expect (argo .Spec .ResourceHealthChecks [1 ].Kind ).To (Equal ("Application" ))
22422242 })
22432243
2244+ It ("should append custom health checks from gitops.customHealthChecks" , func () {
2245+ customYAML := `- group: apps
2246+ kind: Deployment
2247+ check: |
2248+ hs = {}
2249+ hs.status = "Healthy"
2250+ return hs
2251+ - group: batch
2252+ kind: Job
2253+ check: |
2254+ hs = {}
2255+ hs.status = "Progressing"
2256+ return hs`
2257+ argo = newArgoCD ("test-argo" , "test-ns" , PatternsOperatorConfig {"gitops.customHealthChecks" : customYAML })
2258+ Expect (argo .Spec .ResourceHealthChecks ).To (HaveLen (3 ))
2259+ Expect (argo .Spec .ResourceHealthChecks [0 ].Group ).To (Equal ("operators.coreos.com" ))
2260+ Expect (argo .Spec .ResourceHealthChecks [1 ].Group ).To (Equal ("apps" ))
2261+ Expect (argo .Spec .ResourceHealthChecks [1 ].Kind ).To (Equal ("Deployment" ))
2262+ Expect (argo .Spec .ResourceHealthChecks [2 ].Group ).To (Equal ("batch" ))
2263+ Expect (argo .Spec .ResourceHealthChecks [2 ].Kind ).To (Equal ("Job" ))
2264+ })
2265+
2266+ It ("should append custom health checks alongside Application health check when both are enabled" , func () {
2267+ customYAML := `- group: apps
2268+ kind: Deployment
2269+ check: |
2270+ hs = {}
2271+ hs.status = "Healthy"
2272+ return hs`
2273+ argo = newArgoCD ("test-argo" , "test-ns" , PatternsOperatorConfig {
2274+ "gitops.applicationHealthCheckEnabled" : "true" ,
2275+ "gitops.customHealthChecks" : customYAML ,
2276+ })
2277+ Expect (argo .Spec .ResourceHealthChecks ).To (HaveLen (3 ))
2278+ Expect (argo .Spec .ResourceHealthChecks [0 ].Group ).To (Equal ("operators.coreos.com" ))
2279+ Expect (argo .Spec .ResourceHealthChecks [1 ].Group ).To (Equal ("argoproj.io" ))
2280+ Expect (argo .Spec .ResourceHealthChecks [2 ].Group ).To (Equal ("apps" ))
2281+ })
2282+
2283+ It ("should handle invalid YAML in gitops.customHealthChecks gracefully" , func () {
2284+ argo = newArgoCD ("test-argo" , "test-ns" , PatternsOperatorConfig {"gitops.customHealthChecks" : "not: valid: yaml: list" })
2285+ Expect (argo .Spec .ResourceHealthChecks ).To (HaveLen (1 ))
2286+ Expect (argo .Spec .ResourceHealthChecks [0 ].Group ).To (Equal ("operators.coreos.com" ))
2287+ })
2288+
2289+ It ("should not add custom health checks when gitops.customHealthChecks is empty" , func () {
2290+ argo = newArgoCD ("test-argo" , "test-ns" , PatternsOperatorConfig {"gitops.customHealthChecks" : "" })
2291+ Expect (argo .Spec .ResourceHealthChecks ).To (HaveLen (1 ))
2292+ })
2293+
22442294})
22452295
22462296var _ = Describe ("commonSyncPolicy" , func () {
0 commit comments