@@ -738,6 +738,171 @@ func TestCatalogdControllerReconcile(t *testing.T) {
738738 },
739739 },
740740 },
741+ {
742+ name : "after catalog availability set to enable, finalizer should be added" ,
743+ source : & MockSource {
744+ result : & source.Result {
745+ State : source .StateUnpacked ,
746+ FS : & fstest.MapFS {},
747+ },
748+ },
749+ store : & MockStore {},
750+ catalog : & catalogdv1.ClusterCatalog {
751+ ObjectMeta : metav1.ObjectMeta {
752+ Name : "catalog" ,
753+ Finalizers : []string {},
754+ },
755+ Spec : catalogdv1.ClusterCatalogSpec {
756+ Source : catalogdv1.CatalogSource {
757+ Type : catalogdv1 .SourceTypeImage ,
758+ Image : & catalogdv1.ImageSource {
759+ Ref : "my.org/someimage:latest" ,
760+ },
761+ },
762+ AvailabilityMode : catalogdv1 .AvailabilityModeAvailable ,
763+ },
764+ Status : catalogdv1.ClusterCatalogStatus {
765+ URLs : & catalogdv1.ClusterCatalogURLs {Base : "URL" },
766+ ResolvedSource : & catalogdv1.ResolvedCatalogSource {
767+ Type : catalogdv1 .SourceTypeImage ,
768+ Image : & catalogdv1.ResolvedImageSource {
769+ Ref : "" ,
770+ },
771+ },
772+ Conditions : []metav1.Condition {
773+ {
774+ Type : catalogdv1 .TypeServing ,
775+ Status : metav1 .ConditionFalse ,
776+ Reason : catalogdv1 .ReasonUnavailable ,
777+ },
778+ {
779+ Type : catalogdv1 .TypeProgressing ,
780+ Status : metav1 .ConditionFalse ,
781+ Reason : catalogdv1 .ReasonUserSpecifiedUnavailable ,
782+ },
783+ },
784+ },
785+ },
786+ expectedCatalog : & catalogdv1.ClusterCatalog {
787+ ObjectMeta : metav1.ObjectMeta {
788+ Name : "catalog" ,
789+ Finalizers : []string {fbcDeletionFinalizer },
790+ },
791+ Spec : catalogdv1.ClusterCatalogSpec {
792+ Source : catalogdv1.CatalogSource {
793+ Type : catalogdv1 .SourceTypeImage ,
794+ Image : & catalogdv1.ImageSource {
795+ Ref : "my.org/someimage:latest" ,
796+ },
797+ },
798+ AvailabilityMode : catalogdv1 .AvailabilityModeAvailable ,
799+ },
800+ Status : catalogdv1.ClusterCatalogStatus {
801+ URLs : & catalogdv1.ClusterCatalogURLs {Base : "URL" },
802+ ResolvedSource : & catalogdv1.ResolvedCatalogSource {
803+ Type : catalogdv1 .SourceTypeImage ,
804+ Image : & catalogdv1.ResolvedImageSource {
805+ Ref : "" ,
806+ },
807+ },
808+ Conditions : []metav1.Condition {
809+ {
810+ Type : catalogdv1 .TypeServing ,
811+ Status : metav1 .ConditionFalse ,
812+ Reason : catalogdv1 .ReasonUnavailable ,
813+ },
814+ {
815+ Type : catalogdv1 .TypeProgressing ,
816+ Status : metav1 .ConditionFalse ,
817+ Reason : catalogdv1 .ReasonUserSpecifiedUnavailable ,
818+ },
819+ },
820+ },
821+ },
822+ },
823+ {
824+ name : "after catalog availability set to enable and finalizer added, the status should get updated" ,
825+ source : & MockSource {
826+ result : & source.Result {
827+ State : source .StateUnpacked ,
828+ FS : & fstest.MapFS {},
829+ },
830+ },
831+ store : & MockStore {},
832+ catalog : & catalogdv1.ClusterCatalog {
833+ ObjectMeta : metav1.ObjectMeta {
834+ Name : "catalog" ,
835+ Finalizers : []string {fbcDeletionFinalizer },
836+ },
837+ Spec : catalogdv1.ClusterCatalogSpec {
838+ Source : catalogdv1.CatalogSource {
839+ Type : catalogdv1 .SourceTypeImage ,
840+ Image : & catalogdv1.ImageSource {
841+ Ref : "my.org/someimage:latest" ,
842+ },
843+ },
844+ AvailabilityMode : catalogdv1 .AvailabilityModeAvailable ,
845+ },
846+ Status : catalogdv1.ClusterCatalogStatus {
847+ URLs : & catalogdv1.ClusterCatalogURLs {Base : "URL" },
848+ LastUnpacked : & metav1.Time {},
849+ ResolvedSource : & catalogdv1.ResolvedCatalogSource {
850+ Type : catalogdv1 .SourceTypeImage ,
851+ Image : & catalogdv1.ResolvedImageSource {
852+ Ref : "" ,
853+ },
854+ },
855+ Conditions : []metav1.Condition {
856+ {
857+ Type : catalogdv1 .TypeServing ,
858+ Status : metav1 .ConditionFalse ,
859+ Reason : catalogdv1 .ReasonUnavailable ,
860+ },
861+ {
862+ Type : catalogdv1 .TypeProgressing ,
863+ Status : metav1 .ConditionFalse ,
864+ Reason : catalogdv1 .ReasonUserSpecifiedUnavailable ,
865+ },
866+ },
867+ },
868+ },
869+ expectedCatalog : & catalogdv1.ClusterCatalog {
870+ ObjectMeta : metav1.ObjectMeta {
871+ Name : "catalog" ,
872+ Finalizers : []string {fbcDeletionFinalizer },
873+ },
874+ Spec : catalogdv1.ClusterCatalogSpec {
875+ Source : catalogdv1.CatalogSource {
876+ Type : catalogdv1 .SourceTypeImage ,
877+ Image : & catalogdv1.ImageSource {
878+ Ref : "my.org/someimage:latest" ,
879+ },
880+ },
881+ AvailabilityMode : catalogdv1 .AvailabilityModeAvailable ,
882+ },
883+ Status : catalogdv1.ClusterCatalogStatus {
884+ URLs : & catalogdv1.ClusterCatalogURLs {Base : "URL" },
885+ ResolvedSource : & catalogdv1.ResolvedCatalogSource {
886+ Type : catalogdv1 .SourceTypeImage ,
887+ Image : & catalogdv1.ResolvedImageSource {
888+ Ref : "" ,
889+ },
890+ },
891+ Conditions : []metav1.Condition {
892+ {
893+ Type : catalogdv1 .TypeServing ,
894+ Status : metav1 .ConditionTrue ,
895+ Reason : catalogdv1 .ReasonAvailable ,
896+ },
897+ {
898+ Type : catalogdv1 .TypeProgressing ,
899+ Status : metav1 .ConditionTrue ,
900+ Reason : catalogdv1 .ReasonSucceeded ,
901+ },
902+ },
903+ },
904+ },
905+ },
741906 } {
742907 t .Run (tt .name , func (t * testing.T ) {
743908 reconciler := & ClusterCatalogReconciler {
0 commit comments