@@ -822,6 +822,71 @@ func TestCreateOrUpdateResource(t *testing.T) {
822822 g .Expect (err .Error ()).To (ContainSubstring ("failed to reconcile tags" ))
823823 })
824824
825+ t .Run ("with tags not done error and readyErr" , func (t * testing.T ) {
826+ g := NewGomegaWithT (t )
827+
828+ sch := runtime .NewScheme ()
829+ g .Expect (asoresourcesv1 .AddToScheme (sch )).To (Succeed ())
830+ c := fakeclient .NewClientBuilder ().
831+ WithScheme (sch ).
832+ Build ()
833+ s := New (c , clusterName )
834+
835+ mockCtrl := gomock .NewController (t )
836+ specMock := struct {
837+ * mock_azure.MockASOResourceSpecGetter
838+ * mock_aso.MockTagsGetterSetter
839+ }{
840+ MockASOResourceSpecGetter : mock_azure .NewMockASOResourceSpecGetter (mockCtrl ),
841+ MockTagsGetterSetter : mock_aso .NewMockTagsGetterSetter (mockCtrl ),
842+ }
843+ specMock .MockASOResourceSpecGetter .EXPECT ().ResourceRef ().Return (& asoresourcesv1.ResourceGroup {
844+ ObjectMeta : metav1.ObjectMeta {
845+ Name : "name" ,
846+ Namespace : "namespace" ,
847+ },
848+ })
849+ specMock .MockASOResourceSpecGetter .EXPECT ().Parameters (gomockinternal .AContext (), gomock .Any ()).DoAndReturn (func (_ context.Context , group * asoresourcesv1.ResourceGroup ) (* asoresourcesv1.ResourceGroup , error ) {
850+ return group , nil
851+ })
852+
853+ existing := & asoresourcesv1.ResourceGroup {
854+ ObjectMeta : metav1.ObjectMeta {
855+ Name : "name" ,
856+ Namespace : "namespace" ,
857+ Labels : map [string ]string {
858+ infrav1 .OwnedByClusterLabelKey : clusterName ,
859+ },
860+ Annotations : map [string ]string {
861+ asoannotations .ReconcilePolicy : string (asoannotations .ReconcilePolicyManage ),
862+ },
863+ },
864+ Spec : asoresourcesv1.ResourceGroup_Spec {
865+ Tags : map [string ]string {"desired" : "tags" },
866+ },
867+ Status : asoresourcesv1.ResourceGroup_STATUS {
868+ Tags : map [string ]string {"actual" : "tags" },
869+ Conditions : []conditions.Condition {
870+ {
871+ Type : conditions .ConditionTypeReady ,
872+ Status : metav1 .ConditionFalse ,
873+ Message : "not ready :(" ,
874+ },
875+ },
876+ },
877+ }
878+
879+ specMock .MockTagsGetterSetter .EXPECT ().GetActualTags (gomock .Any ()).Return (existing .Status .Tags , nil )
880+ specMock .MockTagsGetterSetter .EXPECT ().GetDesiredTags (gomock .Any ()).Return (existing .Spec .Tags , nil )
881+
882+ ctx := context .Background ()
883+ g .Expect (c .Create (ctx , existing )).To (Succeed ())
884+
885+ result , err := s .CreateOrUpdateResource (ctx , specMock , "service" )
886+ g .Expect (result ).To (BeNil ())
887+ g .Expect (err .Error ()).To (ContainSubstring ("not ready :(" ))
888+ })
889+
825890 t .Run ("reconcile policy annotation resets after un-pause" , func (t * testing.T ) {
826891 g := NewGomegaWithT (t )
827892
0 commit comments