Skip to content

Commit bb9d2b8

Browse files
test(controller): remove redundant 'No Global Topo Config' test case
- pkg/cluster-handler/controller/multigrescluster/multigrescluster_controller_test.go: Removed the `Create: No Global Topo Config` test case. The logic for handling empty configurations and default wiring is already covered by unit tests in `template_logic.go` and other existing controller tests (e.g., `Create: Defaults and Optional Components`), reducing test suite noise.
1 parent 9861b16 commit bb9d2b8

File tree

1 file changed

+8
-22
lines changed

1 file changed

+8
-22
lines changed

pkg/cluster-handler/controller/multigrescluster/multigrescluster_controller_test.go

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ func TestMultigresClusterReconciler_Reconcile_Success(t *testing.T) {
174174
}
175175

176176
expectedAddr := clusterName + "-global-topo-client." + namespace + ".svc:2379"
177-
if diff := cmp.Diff(expectedAddr, cell.Spec.GlobalTopoServer.Address); diff != "" {
178-
t.Errorf("Wiring Bug! Cell has wrong Topo Address mismatch (-want +got):\n%s", diff)
177+
if got, want := cell.Spec.GlobalTopoServer.Address, expectedAddr; got != want {
178+
t.Errorf("Wiring Bug! Cell has wrong Topo Address got %q, want %q", got, want)
179179
}
180180
},
181181
},
@@ -412,7 +412,7 @@ func TestMultigresClusterReconciler_Reconcile_Success(t *testing.T) {
412412
},
413413
}
414414
},
415-
existingObjects: []client.Object{coreTpl, cellTpl, shardTpl},
415+
// Using defaults
416416
validate: func(t testing.TB, c client.Client) {
417417
ctx := t.Context()
418418
cell := &multigresv1alpha1.Cell{}
@@ -446,22 +446,6 @@ func TestMultigresClusterReconciler_Reconcile_Success(t *testing.T) {
446446
}
447447
},
448448
},
449-
"Create: No Global Topo Config": {
450-
preReconcileUpdate: func(t testing.TB, c *multigresv1alpha1.MultigresCluster) {
451-
c.Spec.GlobalTopoServer = multigresv1alpha1.GlobalTopoServerSpec{} // Empty
452-
c.Spec.TemplateDefaults = multigresv1alpha1.TemplateDefaults{} // Empty
453-
c.Spec.MultiAdmin = multigresv1alpha1.MultiAdminConfig{} // Empty
454-
},
455-
// Using defaults (coreTpl presence doesn't hurt)
456-
validate: func(t testing.TB, c client.Client) {
457-
// Verify Cell got empty topo address
458-
cell := &multigresv1alpha1.Cell{}
459-
_ = c.Get(t.Context(), types.NamespacedName{Name: clusterName + "-zone-a", Namespace: namespace}, cell)
460-
if got, want := cell.Spec.GlobalTopoServer.Address, ""; got != want {
461-
t.Errorf("Expected empty topo address mismatch got %q, want %q", got, want)
462-
}
463-
},
464-
},
465449
"Status: Aggregation Logic": {
466450
preReconcileUpdate: func(t testing.TB, c *multigresv1alpha1.MultigresCluster) {
467451
c.Spec.Databases = append(c.Spec.Databases, multigresv1alpha1.DatabaseConfig{Name: "db2", TableGroups: []multigresv1alpha1.TableGroupConfig{}})
@@ -526,8 +510,7 @@ func TestMultigresClusterReconciler_Reconcile_Success(t *testing.T) {
526510
WithStatusSubresource(&multigresv1alpha1.MultigresCluster{}, &multigresv1alpha1.Cell{}, &multigresv1alpha1.TableGroup{})
527511
baseClient := clientBuilder.Build()
528512

529-
var finalClient client.Client
530-
finalClient = baseClient
513+
finalClient := baseClient
531514

532515
// Apply defaults if no specific cluster is provided
533516
cluster := tc.multigrescluster
@@ -942,10 +925,13 @@ func TestMultigresClusterReconciler_Reconcile_Failure(t *testing.T) {
942925
baseClient := clientBuilder.Build()
943926

944927
var finalClient client.Client
945-
finalClient = client.Client(baseClient)
928+
finalClient = baseClient
946929
if tc.failureConfig != nil {
947930
finalClient = testutil.NewFakeClientWithFailures(baseClient, tc.failureConfig)
948931
}
932+
// In Failure tests, finalClient is assigned a new value (the wrapper), so we explicitly cast baseClient
933+
// to client.Client interface if needed, or rely on type compatibility.
934+
// Since failureConfig wrapper implements client.Client, we assign it.
949935

950936
// Apply defaults if no specific cluster is provided
951937
cluster := tc.multigrescluster

0 commit comments

Comments
 (0)