@@ -273,3 +273,62 @@ func TestEquivalentTemplatesRecreateOption(t *testing.T) {
273273 t .Fatal ("Expected the templates to be equivalent" )
274274 }
275275}
276+
277+ func TestEquivalentTemplatesOperatorPolicyComplianceConfig (t * testing.T ) {
278+ existing := & unstructured.Unstructured {
279+ Object : map [string ]interface {}{
280+ "apiVersion" : "policy.open-cluster-management.io/v1beta1" ,
281+ "kind" : "OperatorPolicy" ,
282+ "metadata" : map [string ]interface {}{
283+ "name" : "test-policy" ,
284+ },
285+ "spec" : map [string ]interface {}{
286+ "remediationAction" : "inform" ,
287+ "severity" : "medium" ,
288+ "complianceType" : "musthave" ,
289+ "subscription:" : map [string ]interface {}{
290+ "channel" : "stable-3.10" ,
291+ "name" : "project-quay" ,
292+ "namespace" : "operator-policy-testns" ,
293+ "source" : "operatorhubio-catalog" ,
294+ "sourceNamespace" : "olm" ,
295+ "startingCSV" : "quay-operator.v3.10.0" ,
296+ },
297+ "upgradeApproval" : "Automatic" ,
298+ "complianceConfig" : map [string ]interface {}{
299+ "catalogSourceUnhealthy" : "Compliant" ,
300+ "deploymentsUnavailable" : "NonCompliant" ,
301+ "upgradesAvailable" : "Compliant" ,
302+ },
303+ },
304+ },
305+ }
306+
307+ template := & unstructured.Unstructured {
308+ Object : map [string ]interface {}{
309+ "apiVersion" : "policy.open-cluster-management.io/v1beta1" ,
310+ "kind" : "OperatorPolicy" ,
311+ "metadata" : map [string ]interface {}{
312+ "name" : "test-policy" ,
313+ },
314+ "spec" : map [string ]interface {}{
315+ "remediationAction" : "inform" ,
316+ "severity" : "medium" ,
317+ "complianceType" : "musthave" ,
318+ "subscription:" : map [string ]interface {}{
319+ "channel" : "stable-3.10" ,
320+ "name" : "project-quay" ,
321+ "namespace" : "operator-policy-testns" ,
322+ "source" : "operatorhubio-catalog" ,
323+ "sourceNamespace" : "olm" ,
324+ "startingCSV" : "quay-operator.v3.10.0" ,
325+ },
326+ "upgradeApproval" : "Automatic" ,
327+ },
328+ },
329+ }
330+
331+ if ! equivalentTemplates (existing , template ) {
332+ t .Fatal ("Expected the templates to be equivalent" )
333+ }
334+ }
0 commit comments