feat: 初始化 controller 状态机
This commit is contained in:
@@ -82,8 +82,22 @@ var _ = Describe("PostgreSQLTenant Controller", func() {
|
||||
NamespacedName: typeNamespacedName,
|
||||
})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
// TODO(user): Add more specific assertions depending on your controller's reconciliation logic.
|
||||
// Example: If you expect a certain status condition after reconciliation, verify it here.
|
||||
|
||||
actual := &databasev1alpha1.PostgreSQLTenant{}
|
||||
Expect(k8sClient.Get(ctx, typeNamespacedName, actual)).To(Succeed())
|
||||
Expect(actual.Status.Phase).To(Equal(databasev1alpha1.PostgreSQLTenantPhasePending))
|
||||
Expect(actual.Status.Conditions).To(ConsistOf(And(
|
||||
HaveField("Type", databasev1alpha1.ConditionTypeReady),
|
||||
HaveField("Status", metav1.ConditionUnknown),
|
||||
HaveField("Reason", databasev1alpha1.ReasonReconciling),
|
||||
HaveField("ObservedGeneration", actual.Generation),
|
||||
)))
|
||||
|
||||
resourceVersion := actual.ResourceVersion
|
||||
_, err = controllerReconciler.Reconcile(ctx, reconcile.Request{NamespacedName: typeNamespacedName})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(k8sClient.Get(ctx, typeNamespacedName, actual)).To(Succeed())
|
||||
Expect(actual.ResourceVersion).To(Equal(resourceVersion), "an unchanged status must not be patched")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user