secret deletion

This commit is contained in:
kkb0318
2024-04-11 20:59:17 +09:00
parent 720bc912b9
commit 1b9ccebbc5
13 changed files with 155 additions and 65 deletions
@@ -38,13 +38,16 @@ var _ = Describe("IRSASetup Controller", func() {
Context("When reconciling a resource", func() {
const resourceName = "test-resource"
ctx := context.Background()
typeNamespacedName := types.NamespacedName{
Name: resourceName,
Namespace: "default", // TODO(user):Modify as needed
Namespace: "default",
}
irsasetup := &irsav1alpha1.IRSASetup{
ObjectMeta: metav1.ObjectMeta{
Name: resourceName,
Namespace: "default",
},
}
irsasetup := &irsav1alpha1.IRSASetup{}
BeforeEach(func() {
By("creating the custom resource for the Kind IRSASetup")
@@ -69,17 +72,12 @@ var _ = Describe("IRSASetup Controller", func() {
}
})
AfterEach(func() {
// TODO(user): Cleanup logic after each test, like removing the resource instance.
resource := &irsav1alpha1.IRSASetup{}
err := k8sClient.Get(ctx, typeNamespacedName, resource)
Expect(err).NotTo(HaveOccurred())
By("Cleanup the specific resource instance IRSASetup")
Expect(k8sClient.Delete(ctx, resource)).To(Succeed())
})
It("should successfully reconcile the resource", func() {
awsClient := newMockAwsClient()
expected := []types.NamespacedName{
{Name: "name", Namespace: "default"},
}
By("Reconciling the created resource")
controllerReconciler := &IRSASetupReconciler{
Client: k8sClient,
@@ -91,8 +89,24 @@ var _ = Describe("IRSASetup 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.
_, err = controllerReconciler.Reconcile(ctx, reconcile.Request{
NamespacedName: typeNamespacedName,
})
Expect(err).NotTo(HaveOccurred())
for _, expect := range expected {
checkExist(expect, newSecret)
}
By("removing the custom resource for the Kind")
Eventually(func() error {
return k8sClient.Delete(ctx, irsasetup)
}, timeout).Should(Succeed())
_, err = controllerReconciler.Reconcile(ctx, reconcile.Request{
NamespacedName: typeNamespacedName,
})
Expect(err).To(Not(HaveOccurred()))
for _, expect := range expected {
checkNoExist(expect, newSecret)
}
})
})
})