From d6b751a0b83e874dd1e9a9674aa7311fc350c6ed Mon Sep 17 00:00:00 2001 From: Francisco Barros <francisco.borges.aurindo.barros@cern.ch> Date: Tue, 18 Jan 2022 18:25:50 +0100 Subject: [PATCH] Added empty unit tests TODO, renamed func --- controllers/drupalsite_controller.go | 4 ++-- controllers/drupalsite_controller_test.go | 16 +++++++++++++++- controllers/reconciler_utils.go | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/controllers/drupalsite_controller.go b/controllers/drupalsite_controller.go index 52cf4c15..11e02690 100644 --- a/controllers/drupalsite_controller.go +++ b/controllers/drupalsite_controller.go @@ -339,8 +339,8 @@ func (r *DrupalSiteReconciler) Reconcile(ctx context.Context, req ctrl.Request) setErrorCondition(drupalSite, reconcileErr) return r.updateCRStatusOrFailReconcile(ctx, log, drupalSite) case updateNeeded: - log.Info("Updating DrupalProjectConfig " + drupalProjectConfig.Namespace) - r.updateDrupalProjectConfigCRorFailReconcile(ctx, log, drupalProjectConfig) + log.Info("Updating DrupalProjectConfig ") + r.updateDrupalProjectConfigCR(ctx, log, drupalProjectConfig) } // Check if current instance is the Primary Drupalsite updateNeeded, reconcileErr = r.checkIfPrimaryDrupalsite(ctx, drupalSite, drupalProjectConfig) diff --git a/controllers/drupalsite_controller_test.go b/controllers/drupalsite_controller_test.go index 723ea3f4..c73af3a5 100644 --- a/controllers/drupalsite_controller_test.go +++ b/controllers/drupalsite_controller_test.go @@ -1918,7 +1918,21 @@ var _ = Describe("DrupalSite controller", func() { }) }) }) - + Describe("TODO Using DrupalProjectConfig", func() { + Context("", func() { + It("", func() { + // Tests that should be done + // Create a new project without any DrupalProjectConfig, operator logs Warning: Project $PROJECT does not contain any DrupalProjectConfig! + // Createda DrupalProjectConfig with one website and saw spec getting automatically filled, $PROJECT only 1 drupalsite\"$DRUPALSITE\", which is considered the primary production site + // Creation of a second website does not affect DrupalProjectConfig + // Creation of DrupalProjectConfig with 2 DrupalSites in place will not automatically fill spec.primarySiteName + // Deletion of 2 instances to 1, and spec.primarySiteName=="", will auto-fill + // If spec.primarySiteName!="", it is never auto-filled, not even with just one instance being created + // By default DrupalSite.status.isPrimary is false + // Editing DrupalProjectConfig will reflect changes on DrupalSite.status.isPrimary + }) + }) + }) Describe("Deleting the drupalsite object", func() { Context("With critical QoS", func() { It("Should be deleted successfully", func() { diff --git a/controllers/reconciler_utils.go b/controllers/reconciler_utils.go index 0cf21834..9e5030c3 100644 --- a/controllers/reconciler_utils.go +++ b/controllers/reconciler_utils.go @@ -121,7 +121,7 @@ func setDBUpdatesPending(drp *webservicesv1a1.DrupalSite) (update bool) { } // updateCRorFailReconcile tries to update the Custom Resource and logs any error -func (r *DrupalSiteReconciler) updateDrupalProjectConfigCRorFailReconcile(ctx context.Context, log logr.Logger, dpc *webservicesv1a1.DrupalProjectConfig) { +func (r *DrupalSiteReconciler) updateDrupalProjectConfigCR(ctx context.Context, log logr.Logger, dpc *webservicesv1a1.DrupalProjectConfig) { if err := r.Update(ctx, dpc); err != nil { if k8sapierrors.IsConflict(err) { log.V(4).Info("Object changed while reconciling. Requeuing.") -- GitLab