@@ -1127,6 +1127,51 @@ func TestModernReconciler(t *testing.T) {
11271127 },
11281128 want : want {result : reconcile.Result {RequeueAfter : defaultPollInterval }},
11291129 },
1130+ "ExternalResourceUpToDateAsyncOperationInProgress" : {
1131+ reason : "When an async operation is in progress, Synced should be set to ReconcilePending instead of ReconcileSuccess." ,
1132+ args : args {
1133+ m : & fake.Manager {
1134+ Client : & test.MockClient {
1135+ MockGet : modernManagedMockGetFn (nil , 42 ),
1136+ MockStatusUpdate : test .MockSubResourceUpdateFn (func (_ context.Context , obj client.Object , _ ... client.SubResourceUpdateOption ) error {
1137+ want := newModernManaged (42 )
1138+ want .SetConditions (xpv1 .ReconcilePending ("Async operation in progress" ).WithObservedGeneration (42 ))
1139+
1140+ if diff := cmp .Diff (want , obj , test .EquateConditions ()); diff != "" {
1141+ reason := "An async-in-progress reconcile should set ReconcilePending, not ReconcileSuccess."
1142+ t .Errorf ("\n Reason: %s\n -want, +got:\n %s" , reason , diff )
1143+ }
1144+
1145+ return nil
1146+ }),
1147+ },
1148+ Scheme : fake .SchemeWith (& fake.ModernManaged {}),
1149+ },
1150+ mg : resource .ManagedKind (fake .GVK (& fake.ModernManaged {})),
1151+ o : []ReconcilerOption {
1152+ WithInitializers (),
1153+ WithReferenceResolver (ReferenceResolverFn (func (_ context.Context , _ resource.Managed ) error { return nil })),
1154+ WithExternalConnector (ExternalConnectorFn (func (_ context.Context , _ resource.Managed ) (ExternalClient , error ) {
1155+ c := & ExternalClientFns {
1156+ ObserveFn : func (_ context.Context , _ resource.Managed ) (ExternalObservation , error ) {
1157+ return ExternalObservation {
1158+ ResourceExists : true ,
1159+ ResourceUpToDate : true ,
1160+ AsyncOperationInProgress : true ,
1161+ }, nil
1162+ },
1163+ DisconnectFn : func (_ context.Context ) error {
1164+ return nil
1165+ },
1166+ }
1167+
1168+ return c , nil
1169+ })),
1170+ WithFinalizer (resource.FinalizerFns {AddFinalizerFn : func (_ context.Context , _ resource.Object ) error { return nil }}),
1171+ },
1172+ },
1173+ want : want {result : reconcile.Result {RequeueAfter : defaultPollInterval }},
1174+ },
11301175 "ExternalResourceUpToDateWithJitter" : {
11311176 reason : "When the external resource exists and is up to date a requeue should be triggered after a long wait with jitter added." ,
11321177 args : args {
0 commit comments