@@ -284,7 +284,7 @@ func TestGenerateTiers(t *testing.T) {
284284 require .Len (t , tierTmpls .Items , 16 ) // 4 items for advanced and base tiers + 3 for nocluster tier + 4 for appstudio
285285 origTemplates := map [string ]* toolchainv1alpha1.TierTemplate {}
286286 for _ , tmpl := range tierTmpls .Items {
287- origTemplates [tmpl .Name ] = & tmpl
287+ origTemplates [tmpl .Name ] = tmpl . DeepCopy ()
288288 }
289289
290290 // when calling CreateOrUpdateResources a second time
@@ -299,10 +299,13 @@ func TestGenerateTiers(t *testing.T) {
299299 require .Len (t , tierTmpls .Items , 16 ) // 4 items for advanced and base tiers + 3 for nocluster tier + 4 for appstudio
300300 // check that the tier templates are unchanged
301301 for _ , tierTmpl := range tierTmpls .Items {
302- assert .True (t , reflect .DeepEqual (origTemplates [tierTmpl .Name ].Spec , tierTmpl .Spec ))
303- }
304-
305- // verify that 4 NSTemplateTier CRs were created:
302+ // these two should always mean the same thing. If they don't, it means there's an issue with serde of
303+ // the templates where template json -> object in cluster -> template json doesn't yield the same thing.
304+ // (the json reprentation is used to detect generation change in our test.Client).
305+ // This is usually caused by e.g explicitly using a zero value of some property in the template file.
306+ assert .True (t , reflect .DeepEqual (origTemplates [tierTmpl .Name ].Spec , tierTmpl .Spec ), "deep equal different on %T %s" , tierTmpl , tierTmpl .Name )
307+ assert .Equal (t , int64 (1 ), tierTmpl .Generation , "generation different on %T %s" , tierTmpl , tierTmpl .Name ) // unchanged
308+ } // verify that 4 NSTemplateTier CRs were created:
306309 for _ , tierName := range []string {"advanced" , "base" , "nocluster" , "appstudio" } {
307310 tier := toolchainv1alpha1.NSTemplateTier {}
308311 err = clt .Get (context .TODO (), types.NamespacedName {Namespace : namespace , Name : tierName }, & tier )
0 commit comments