@@ -462,17 +462,39 @@ func TestTierTemplateRevision(t *testing.T) {
462462 require .NoError (t , err )
463463
464464 // then
465- // a new TTR was created
466- updatedTTRs , err := hostAwait .WaitForTTRs (t , customTier .Name , wait .GreaterOrEqual (len (ttrs ))) //there is already a cleanup controller
467- require .NoError (t , err )
468465 // get the updated nstemplatetier
469466 updatedCustomTier , err := wait .For (t , hostAwait .Awaitility , & toolchainv1alpha1.NSTemplateTier {}).
470467 WithNameMatching (customTier .Name , func (actual * toolchainv1alpha1.NSTemplateTier ) bool {
471468 newTTR , found := actual .Status .Revisions [actual .Spec .ClusterResources .TemplateRef ]
472469 return found && newTTR != "" && newTTR != ttrToBeModified
473470 })
471+ require .NoError (t , err )
474472 newTTR := updatedCustomTier .Status .Revisions [updatedCustomTier .Spec .ClusterResources .TemplateRef ]
475473
474+ // a new TTR was created
475+ // wait until the new TTR name appears in the list
476+ updatedTTRs , err := hostAwait .WaitForTTRs (
477+ t ,
478+ customTier .Name ,
479+ wait.TierTemplateRevisionWaitCriterion {
480+ Match : func (actual []toolchainv1alpha1.TierTemplateRevision ) bool {
481+ for _ , tr := range actual {
482+ if tr .Name == newTTR {
483+ return true
484+ }
485+ }
486+ return false
487+ },
488+ Diff : func (actual []toolchainv1alpha1.TierTemplateRevision ) string {
489+ names := make ([]string , 0 , len (actual ))
490+ for _ , tr := range actual {
491+ names = append (names , tr .Name )
492+ }
493+ return fmt .Sprintf ("expected new TTR %q in list: %v" , newTTR , names )
494+ },
495+ },
496+ )
497+ require .NoError (t , err )
476498 // check that it has the updated crq
477499 checkThatTTRContainsCRQ (t , newTTR , updatedTTRs , updatedCRQ )
478500
@@ -488,7 +510,6 @@ func TestTierTemplateRevision(t *testing.T) {
488510 // when
489511 // we increase the parameter for the deployment quota
490512 customTier = tiers .UpdateCustomNSTemplateTier (t , hostAwait , customTier , tiers .WithParameter ("DEPLOYMENT_QUOTA" , "100" ))
491- require .NoError (t , err )
492513
493514 // then
494515 // retrieve new tier once the ttrs were created and the revision field updated
0 commit comments