@@ -5,62 +5,81 @@ import (
55 . "github.com/onsi/gomega"
66)
77
8- var _ = Describe ("PatternsOperatorConfig getValueWithDefault " , func () {
8+ var _ = Describe ("PatternsOperatorConfig get values " , func () {
99 Context ("when the key exists in the config" , func () {
1010 It ("should return the config value" , func () {
1111 config := PatternsOperatorConfig {
1212 "gitops.channel" : "custom-channel" ,
1313 }
14- Expect (config .getValueWithDefault ("gitops.channel" )).To (Equal ("custom-channel" ))
14+ Expect (config .getStringValue ("gitops.channel" )).To (Equal ("custom-channel" ))
1515 })
1616 })
1717
1818 Context ("when the key does not exist in config but exists in defaults" , func () {
1919 It ("should return the default value for gitops.channel" , func () {
2020 config := PatternsOperatorConfig {}
21- Expect (config .getValueWithDefault ("gitops.channel" )).To (Equal (GitOpsDefaultChannel ))
21+ Expect (config .getStringValue ("gitops.channel" )).To (Equal (GitOpsDefaultChannel ))
2222 })
2323
2424 It ("should return the default value for gitops.catalogSource" , func () {
2525 config := PatternsOperatorConfig {}
26- Expect (config .getValueWithDefault ("gitops.catalogSource" )).To (Equal (GitOpsDefaultCatalogSource ))
26+ Expect (config .getStringValue ("gitops.catalogSource" )).To (Equal (GitOpsDefaultCatalogSource ))
2727 })
2828
2929 It ("should return the default value for gitops.sourceNamespace" , func () {
3030 config := PatternsOperatorConfig {}
31- Expect (config .getValueWithDefault ("gitops.sourceNamespace" )).To (Equal (GitOpsDefaultCatalogSourceNamespace ))
31+ Expect (config .getStringValue ("gitops.sourceNamespace" )).To (Equal (GitOpsDefaultCatalogSourceNamespace ))
3232 })
3333
3434 It ("should return the default value for gitops.installApprovalPlan" , func () {
3535 config := PatternsOperatorConfig {}
36- Expect (config .getValueWithDefault ("gitops.installApprovalPlan" )).To (Equal (GitOpsDefaultApprovalPlan ))
36+ Expect (config .getStringValue ("gitops.installApprovalPlan" )).To (Equal (GitOpsDefaultApprovalPlan ))
37+ })
38+
39+ It ("should return the default value for gitops.csv" , func () {
40+ config := PatternsOperatorConfig {}
41+ Expect (config .getStringValue ("gitops.csv" )).To (Equal ("" ))
3742 })
3843
3944 It ("should return the default value for gitops.additionalArgoAdmins" , func () {
4045 config := PatternsOperatorConfig {}
41- Expect (config .getValueWithDefault ("gitops.additionalArgoAdmins" )).To (Equal ("" ))
46+ Expect (config .getStringValue ("gitops.additionalArgoAdmins" )).To (Equal ("" ))
47+ })
48+
49+ It ("should return the default value for gitops.applicationHealthCheckEnabled" , func () {
50+ config := PatternsOperatorConfig {}
51+ Expect (config .getBoolValue ("gitops.applicationHealthCheckEnabled" )).To (BeFalse ())
4252 })
4353
4454 It ("should return the default value for gitea.chartName" , func () {
4555 config := PatternsOperatorConfig {}
46- Expect (config .getValueWithDefault ("gitea.chartName" )).To (Equal (GiteaChartName ))
56+ Expect (config .getStringValue ("gitea.chartName" )).To (Equal (GiteaChartName ))
4757 })
4858
4959 It ("should return the default value for gitea.helmRepoUrl" , func () {
5060 config := PatternsOperatorConfig {}
51- Expect (config .getValueWithDefault ("gitea.helmRepoUrl" )).To (Equal (GiteaHelmRepoUrl ))
61+ Expect (config .getStringValue ("gitea.helmRepoUrl" )).To (Equal (GiteaHelmRepoUrl ))
5262 })
5363
5464 It ("should return the default value for gitea.chartVersion" , func () {
5565 config := PatternsOperatorConfig {}
56- Expect (config .getValueWithDefault ("gitea.chartVersion" )).To (Equal (GiteaDefaultChartVersion ))
66+ Expect (config .getStringValue ("gitea.chartVersion" )).To (Equal (GiteaDefaultChartVersion ))
67+ })
68+
69+ It ("should return the default value for catalog.image" , func () {
70+ config := PatternsOperatorConfig {}
71+ Expect (config .getStringValue ("catalog.image" )).To (Equal ("" ))
5772 })
5873 })
5974
6075 Context ("when the key does not exist in config or defaults" , func () {
61- It ("should return an empty string" , func () {
76+ It ("should return an empty string for string parameters" , func () {
77+ config := PatternsOperatorConfig {}
78+ Expect (config .getStringValue ("nonexistent.key" )).To (Equal ("" ))
79+ })
80+ It ("should return false for boolean parameters" , func () {
6281 config := PatternsOperatorConfig {}
63- Expect (config .getValueWithDefault ("nonexistent.key" )).To (Equal ( "" ))
82+ Expect (config .getBoolValue ("nonexistent.key" )).To (BeFalse ( ))
6483 })
6584 })
6685
@@ -69,14 +88,14 @@ var _ = Describe("PatternsOperatorConfig getValueWithDefault", func() {
6988 config := PatternsOperatorConfig {
7089 "gitops.channel" : "gitops-1.99" ,
7190 }
72- Expect (config .getValueWithDefault ("gitops.channel" )).To (Equal ("gitops-1.99" ))
91+ Expect (config .getStringValue ("gitops.channel" )).To (Equal ("gitops-1.99" ))
7392 })
7493 })
7594
7695 Context ("when config is nil" , func () {
7796 It ("should return the default value" , func () {
7897 var config PatternsOperatorConfig
79- Expect (config .getValueWithDefault ("gitops.channel" )).To (Equal (GitOpsDefaultChannel ))
98+ Expect (config .getStringValue ("gitops.channel" )).To (Equal (GitOpsDefaultChannel ))
8099 })
81100 })
82101})
@@ -88,18 +107,16 @@ var _ = Describe("DefaultPatternsOperatorConfig", func() {
88107 "gitops.channel" ,
89108 "gitops.sourceNamespace" ,
90109 "gitops.installApprovalPlan" ,
110+ "gitops.csv" ,
111+ "gitops.additionalArgoAdmins" ,
112+ "gitops.applicationHealthCheckEnabled" ,
91113 "gitea.chartName" ,
92114 "gitea.helmRepoUrl" ,
93115 "gitea.chartVersion" ,
116+ "catalog.image" ,
94117 }
95118 for _ , key := range expectedKeys {
96119 Expect (DefaultPatternsOperatorConfig ).To (HaveKey (key ))
97120 }
98121 })
99-
100- It ("should have correct default values" , func () {
101- Expect (DefaultPatternsOperatorConfig ["gitops.catalogSource" ]).To (Equal ("redhat-operators" ))
102- Expect (DefaultPatternsOperatorConfig ["gitops.sourceNamespace" ]).To (Equal ("openshift-marketplace" ))
103- Expect (DefaultPatternsOperatorConfig ["gitops.installApprovalPlan" ]).To (Equal ("Automatic" ))
104- })
105122})
0 commit comments