Skip to content

Commit 4a8f416

Browse files
committed
feat: wip
1 parent 5f3d567 commit 4a8f416

File tree

4 files changed

+393
-113
lines changed

4 files changed

+393
-113
lines changed

internal/controller/postgresql/postgresqlbackup_controller_test.go

Lines changed: 51 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -17,69 +17,59 @@ limitations under the License.
1717
package postgresql
1818

1919
import (
20-
"context"
21-
22-
"k8s.io/apimachinery/pkg/api/errors"
23-
"k8s.io/apimachinery/pkg/types"
24-
"sigs.k8s.io/controller-runtime/pkg/reconcile"
25-
2620
. "github.com/onsi/ginkgo/v2"
27-
. "github.com/onsi/gomega"
28-
29-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
30-
31-
postgresqlv1alpha1 "github.com/easymile/postgresql-operator/api/postgresql/v1alpha1"
21+
// . "github.com/onsi/gomega".
3222
)
3323

3424
var _ = Describe("PostgresqlBackup Controller", func() {
35-
Context("When reconciling a resource", func() {
36-
const resourceName = "test-resource"
37-
38-
ctx := context.Background()
39-
40-
typeNamespacedName := types.NamespacedName{
41-
Name: resourceName,
42-
Namespace: "default", // TODO(user):Modify as needed
43-
}
44-
postgresqlbackup := &postgresqlv1alpha1.PostgresqlBackup{}
45-
46-
BeforeEach(func() {
47-
By("creating the custom resource for the Kind PostgresqlBackup")
48-
err := k8sClient.Get(ctx, typeNamespacedName, postgresqlbackup)
49-
if err != nil && errors.IsNotFound(err) {
50-
resource := &postgresqlv1alpha1.PostgresqlBackup{
51-
ObjectMeta: metav1.ObjectMeta{
52-
Name: resourceName,
53-
Namespace: "default",
54-
},
55-
// TODO(user): Specify other spec details if needed.
56-
}
57-
Expect(k8sClient.Create(ctx, resource)).To(Succeed())
58-
}
59-
})
60-
61-
AfterEach(func() {
62-
// TODO(user): Cleanup logic after each test, like removing the resource instance.
63-
resource := &postgresqlv1alpha1.PostgresqlBackup{}
64-
err := k8sClient.Get(ctx, typeNamespacedName, resource)
65-
Expect(err).NotTo(HaveOccurred())
66-
67-
By("Cleanup the specific resource instance PostgresqlBackup")
68-
Expect(k8sClient.Delete(ctx, resource)).To(Succeed())
69-
})
70-
It("should successfully reconcile the resource", func() {
71-
By("Reconciling the created resource")
72-
controllerReconciler := &PostgresqlBackupReconciler{
73-
Client: k8sClient,
74-
Scheme: k8sClient.Scheme(),
75-
}
76-
77-
_, err := controllerReconciler.Reconcile(ctx, reconcile.Request{
78-
NamespacedName: typeNamespacedName,
79-
})
80-
Expect(err).NotTo(HaveOccurred())
81-
// TODO(user): Add more specific assertions depending on your controller's reconciliation logic.
82-
// Example: If you expect a certain status condition after reconciliation, verify it here.
83-
})
84-
})
25+
// Context("When reconciling a resource", func() {
26+
// const resourceName = "test-resource"
27+
28+
// ctx := context.Background()
29+
30+
// typeNamespacedName := types.NamespacedName{
31+
// Name: resourceName,
32+
// Namespace: "default", // TODO(user):Modify as needed
33+
// }
34+
// postgresqlbackup := &postgresqlv1alpha1.PostgresqlBackup{}
35+
36+
// BeforeEach(func() {
37+
// By("creating the custom resource for the Kind PostgresqlBackup")
38+
// err := k8sClient.Get(ctx, typeNamespacedName, postgresqlbackup)
39+
// if err != nil && errors.IsNotFound(err) {
40+
// resource := &postgresqlv1alpha1.PostgresqlBackup{
41+
// ObjectMeta: metav1.ObjectMeta{
42+
// Name: resourceName,
43+
// Namespace: "default",
44+
// },
45+
// // TODO(user): Specify other spec details if needed.
46+
// }
47+
// Expect(k8sClient.Create(ctx, resource)).To(Succeed())
48+
// }
49+
// })
50+
51+
// AfterEach(func() {
52+
// // TODO(user): Cleanup logic after each test, like removing the resource instance.
53+
// resource := &postgresqlv1alpha1.PostgresqlBackup{}
54+
// err := k8sClient.Get(ctx, typeNamespacedName, resource)
55+
// Expect(err).NotTo(HaveOccurred())
56+
57+
// By("Cleanup the specific resource instance PostgresqlBackup")
58+
// Expect(k8sClient.Delete(ctx, resource)).To(Succeed())
59+
// })
60+
// It("should successfully reconcile the resource", func() {
61+
// By("Reconciling the created resource")
62+
// controllerReconciler := &PostgresqlBackupReconciler{
63+
// Client: k8sClient,
64+
// Scheme: k8sClient.Scheme(),
65+
// }
66+
67+
// _, err := controllerReconciler.Reconcile(ctx, reconcile.Request{
68+
// NamespacedName: typeNamespacedName,
69+
// })
70+
// Expect(err).NotTo(HaveOccurred())
71+
// // TODO(user): Add more specific assertions depending on your controller's reconciliation logic.
72+
// // Example: If you expect a certain status condition after reconciliation, verify it here.
73+
// })
74+
// })
8575
})

internal/controller/postgresql/postgresqlbackupprovider_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,15 @@ func (r *PostgresqlBackupProviderReconciler) validateInstance(
225225
return errors.NewBadRequest("cronjob name mustn't be empty")
226226
}
227227
if len(instance.Spec.CronJobName) > maxNameLength {
228-
return errors.NewBadRequest("cronjob name is greater than supported")
228+
return errors.NewBadRequest("cronjob name length is greater than supported")
229229
}
230230

231231
// Check generated name prefix
232232
if instance.Spec.GeneratedNamePrefix == "" {
233233
return errors.NewBadRequest("GeneratedNamePrefix mustn't be empty")
234234
}
235235
if len(instance.Spec.GeneratedNamePrefix) > maxGeneratedNamePrefixLength {
236-
return errors.NewBadRequest("GeneratedNamePrefix is greater than supported")
236+
return errors.NewBadRequest("GeneratedNamePrefix length is greater than supported")
237237
}
238238

239239
// Default

0 commit comments

Comments
 (0)