@@ -17,10 +17,14 @@ import (
1717)
1818
1919const (
20- // wdControllerTestName / wdControllerTestNS are shared fixtures for the
21- // WorkloadDeployment controller unit tests.
20+ // wdControllerTestName / wdControllerTestNS / wdControllerTestUID are shared
21+ // fixtures for the WorkloadDeployment controller unit tests.
2222 wdControllerTestName = "test-wd"
2323 wdControllerTestNS = "default"
24+ wdControllerTestUID = "wd-uid-test"
25+
26+ // cityCode is the shared CityCode fixture for WorkloadDeployment tests.
27+ cityCode = "DFW"
2428
2529 // testMsgConfigMapNotFound is a representative terminal referenced-data
2630 // message used across the Available-rollup unit tests.
@@ -46,14 +50,14 @@ func TestReconcileInstanceGates_NilController_DoesNotPanic(t *testing.T) {
4650 // Build a deployment with a minimal template so ComputeHash produces a stable hash.
4751 deployment := & computev1alpha.WorkloadDeployment {
4852 ObjectMeta : metav1.ObjectMeta {
49- Name : "test-wd" ,
50- Namespace : "default" ,
51- UID : "wd-uid-test" ,
53+ Name : wdControllerTestName ,
54+ Namespace : wdControllerTestNS ,
55+ UID : wdControllerTestUID ,
5256 },
5357 Spec : computev1alpha.WorkloadDeploymentSpec {
54- CityCode : "DFW" ,
58+ CityCode : cityCode ,
5559 PlacementName : testDefaultPlacement ,
56- WorkloadRef : computev1alpha.WorkloadReference {Name : "test-workload" },
60+ WorkloadRef : computev1alpha.WorkloadReference {Name : rdTestWorkloadName },
5761 ScaleSettings : computev1alpha.HorizontalScaleSettings {
5862 MinReplicas : 2 ,
5963 },
@@ -74,9 +78,9 @@ func TestReconcileInstanceGates_NilController_DoesNotPanic(t *testing.T) {
7478 instanceNilController := computev1alpha.Instance {
7579 ObjectMeta : metav1.ObjectMeta {
7680 Name : "instance-nil-controller" ,
77- Namespace : "default" ,
81+ Namespace : wdControllerTestNS ,
7882 Labels : map [string ]string {
79- computev1alpha .WorkloadDeploymentUIDLabel : "wd-uid-test" ,
83+ computev1alpha .WorkloadDeploymentUIDLabel : wdControllerTestUID ,
8084 },
8185 },
8286 Status : computev1alpha.InstanceStatus {
@@ -98,9 +102,9 @@ func TestReconcileInstanceGates_NilController_DoesNotPanic(t *testing.T) {
98102 instanceWithController := computev1alpha.Instance {
99103 ObjectMeta : metav1.ObjectMeta {
100104 Name : "instance-with-controller" ,
101- Namespace : "default" ,
105+ Namespace : wdControllerTestNS ,
102106 Labels : map [string ]string {
103- computev1alpha .WorkloadDeploymentUIDLabel : "wd-uid-test" ,
107+ computev1alpha .WorkloadDeploymentUIDLabel : wdControllerTestUID ,
104108 },
105109 },
106110 Status : computev1alpha.InstanceStatus {
@@ -122,9 +126,9 @@ func TestReconcileInstanceGates_NilController_DoesNotPanic(t *testing.T) {
122126 instanceReady := computev1alpha.Instance {
123127 ObjectMeta : metav1.ObjectMeta {
124128 Name : "instance-ready" ,
125- Namespace : "default" ,
129+ Namespace : wdControllerTestNS ,
126130 Labels : map [string ]string {
127- computev1alpha .WorkloadDeploymentUIDLabel : "wd-uid-test" ,
131+ computev1alpha .WorkloadDeploymentUIDLabel : wdControllerTestUID ,
128132 },
129133 },
130134 Status : computev1alpha.InstanceStatus {
@@ -188,9 +192,9 @@ func TestReconcileInstanceGates_NilSpecController_DoesNotPanic(t *testing.T) {
188192 t .Parallel ()
189193
190194 deployment := & computev1alpha.WorkloadDeployment {
191- ObjectMeta : metav1.ObjectMeta {Name : "test-wd" , Namespace : "default" , UID : "wd-uid-test" },
195+ ObjectMeta : metav1.ObjectMeta {Name : wdControllerTestName , Namespace : wdControllerTestNS , UID : wdControllerTestUID },
192196 Spec : computev1alpha.WorkloadDeploymentSpec {
193- CityCode : "DFW" ,
197+ CityCode : cityCode ,
194198 PlacementName : testDefaultPlacement ,
195199 WorkloadRef : computev1alpha.WorkloadReference {Name : "test-workload" },
196200 ScaleSettings : computev1alpha.HorizontalScaleSettings {MinReplicas : 1 },
@@ -201,7 +205,7 @@ func TestReconcileInstanceGates_NilSpecController_DoesNotPanic(t *testing.T) {
201205 // Spec.Controller intentionally nil — the network gate-clearing path runs
202206 // (networkReady=true) and must skip this instance instead of panicking.
203207 instanceNilSpecController := computev1alpha.Instance {
204- ObjectMeta : metav1.ObjectMeta {Name : "instance-nil-spec-controller" , Namespace : "default" },
208+ ObjectMeta : metav1.ObjectMeta {Name : "instance-nil-spec-controller" , Namespace : wdControllerTestNS },
205209 }
206210
207211 cl := newProjectFakeClient ()
0 commit comments