@@ -213,3 +213,63 @@ func TestGetDupName(t *testing.T) {
213213 t .Fatal ("Duplicate name not detected" )
214214 }
215215}
216+
217+ func TestEquivalentTemplatesRecreateOption (t * testing.T ) {
218+ existing := & unstructured.Unstructured {
219+ Object : map [string ]interface {}{
220+ "apiVersion" : "policy.open-cluster-management.io/v1" ,
221+ "kind" : "ConfigurationPolicy" ,
222+ "metadata" : map [string ]interface {}{
223+ "name" : "my-policy" ,
224+ "namespace" : "local-cluster" ,
225+ },
226+ "spec" : map [string ]interface {}{
227+ "pruneObjectBehavior" : "None" ,
228+ "object-templates" : []interface {}{
229+ map [string ]interface {}{
230+ "complianceType" : "musthave" ,
231+ "recreateOption" : "None" ,
232+ "objectDefinition" : map [string ]interface {}{
233+ "apiVersion" : "v1" ,
234+ "kind" : "Pod" ,
235+ "metadata" : map [string ]interface {}{
236+ "name" : "nginx-pod-e2e" ,
237+ "namespace" : "default" ,
238+ },
239+ },
240+ },
241+ },
242+ },
243+ },
244+ }
245+
246+ template := & unstructured.Unstructured {
247+ Object : map [string ]interface {}{
248+ "apiVersion" : "policy.open-cluster-management.io/v1" ,
249+ "kind" : "ConfigurationPolicy" ,
250+ "metadata" : map [string ]interface {}{
251+ "name" : "my-policy" ,
252+ "namespace" : "local-cluster" ,
253+ },
254+ "spec" : map [string ]interface {}{
255+ "object-templates" : []interface {}{
256+ map [string ]interface {}{
257+ "complianceType" : "musthave" ,
258+ "objectDefinition" : map [string ]interface {}{
259+ "apiVersion" : "v1" ,
260+ "kind" : "Pod" ,
261+ "metadata" : map [string ]interface {}{
262+ "name" : "nginx-pod-e2e" ,
263+ "namespace" : "default" ,
264+ },
265+ },
266+ },
267+ },
268+ },
269+ },
270+ }
271+
272+ if ! equivalentTemplates (existing , template ) {
273+ t .Fatal ("Expected the templates to be equivalent" )
274+ }
275+ }
0 commit comments