@@ -14,15 +14,19 @@ import (
1414 networkingv1alpha "go.datum.net/network-services-operator/api/v1alpha"
1515)
1616
17- const testMutatedHostname = "mutated.example.com"
17+ const (
18+ testMutatedHostname = "mutated.example.com"
19+ testAPIHostname = "api.example.com"
20+ testCanonicalGatewayHostname = "abc123.gateways.test.local"
21+ )
1822
1923// TestHostnameStatus_DeepCopy verifies that DeepCopy produces an independent
2024// copy of a HostnameStatus value with all nested slices properly duplicated.
2125func TestHostnameStatus_DeepCopy (t * testing.T ) {
2226 t .Parallel ()
2327
2428 original := networkingv1alpha.HostnameStatus {
25- Hostname : "api.example.com" ,
29+ Hostname : testAPIHostname ,
2630 Conditions : []metav1.Condition {
2731 {
2832 Type : networkingv1alpha .HostnameConditionDNSRecordProgrammed ,
@@ -52,7 +56,7 @@ func TestHostnameStatus_DeepCopy(t *testing.T) {
5256 copied .Conditions [0 ].Message = "mutated message"
5357 copied .Conditions = append (copied .Conditions , metav1.Condition {Type : "Extra" })
5458
55- assert .Equal (t , "api.example.com" , original .Hostname )
59+ assert .Equal (t , testAPIHostname , original .Hostname )
5660 assert .Equal (t , "cname record created in DNSZone \" example-com\" " , original .Conditions [0 ].Message )
5761 assert .Len (t , original .Conditions , 2 , "original conditions should not gain extra element" )
5862}
@@ -87,11 +91,11 @@ func TestHTTPProxyStatus_DeepCopy(t *testing.T) {
8791 t .Parallel ()
8892
8993 original := networkingv1alpha.HTTPProxyStatus {
90- CanonicalHostname : "abc123.gateways.test.local" ,
94+ CanonicalHostname : testCanonicalGatewayHostname ,
9195 Addresses : []gatewayv1.GatewayStatusAddress {
9296 {
9397 Type : ptr .To (gatewayv1 .HostnameAddressType ),
94- Value : "abc123.gateways.test.local" ,
98+ Value : testCanonicalGatewayHostname ,
9599 },
96100 {
97101 Type : ptr .To (gatewayv1 .IPAddressType ),
@@ -100,7 +104,7 @@ func TestHTTPProxyStatus_DeepCopy(t *testing.T) {
100104 },
101105 HostnameStatuses : []networkingv1alpha.HostnameStatus {
102106 {
103- Hostname : "api.example.com" ,
107+ Hostname : testAPIHostname ,
104108 Conditions : []metav1.Condition {
105109 {
106110 Type : networkingv1alpha .HostnameConditionDNSRecordProgrammed ,
@@ -130,11 +134,11 @@ func TestHTTPProxyStatus_DeepCopy(t *testing.T) {
130134
131135 // Mutation independence – addresses.
132136 copied .Addresses [0 ].Value = "mutated"
133- assert .Equal (t , "abc123.gateways.test.local" , original .Addresses [0 ].Value )
137+ assert .Equal (t , testCanonicalGatewayHostname , original .Addresses [0 ].Value )
134138
135139 // Mutation independence – hostname statuses.
136140 copied .HostnameStatuses [0 ].Hostname = testMutatedHostname
137- assert .Equal (t , "api.example.com" , original .HostnameStatuses [0 ].Hostname )
141+ assert .Equal (t , testAPIHostname , original .HostnameStatuses [0 ].Hostname )
138142
139143 // Mutation independence – conditions.
140144 copied .Conditions [0 ].Reason = "Mutated"
@@ -161,13 +165,13 @@ func TestHTTPProxy_DeepCopy(t *testing.T) {
161165 Namespace : "default" ,
162166 },
163167 Spec : networkingv1alpha.HTTPProxySpec {
164- Hostnames : []gatewayv1.Hostname {"api.example.com" , "example.com" },
168+ Hostnames : []gatewayv1.Hostname {testAPIHostname , "example.com" },
165169 },
166170 Status : networkingv1alpha.HTTPProxyStatus {
167- CanonicalHostname : "abc123.gateways.test.local" ,
171+ CanonicalHostname : testCanonicalGatewayHostname ,
168172 HostnameStatuses : []networkingv1alpha.HostnameStatus {
169173 {
170- Hostname : "api.example.com" ,
174+ Hostname : testAPIHostname ,
171175 Conditions : []metav1.Condition {
172176 {
173177 Type : networkingv1alpha .HostnameConditionDNSRecordProgrammed ,
@@ -192,13 +196,13 @@ func TestHTTPProxy_DeepCopy(t *testing.T) {
192196
193197 // Mutation independence.
194198 copied .Status .CanonicalHostname = "mutated"
195- assert .Equal (t , "abc123.gateways.test.local" , original .Status .CanonicalHostname )
199+ assert .Equal (t , testCanonicalGatewayHostname , original .Status .CanonicalHostname )
196200
197201 copied .Status .HostnameStatuses [0 ].Hostname = testMutatedHostname
198- assert .Equal (t , "api.example.com" , original .Status .HostnameStatuses [0 ].Hostname )
202+ assert .Equal (t , testAPIHostname , original .Status .HostnameStatuses [0 ].Hostname )
199203
200204 copied .Spec .Hostnames [0 ] = testMutatedHostname
201- assert .Equal (t , gatewayv1 .Hostname ("api.example.com" ), original .Spec .Hostnames [0 ])
205+ assert .Equal (t , gatewayv1 .Hostname (testAPIHostname ), original .Spec .Hostnames [0 ])
202206}
203207
204208// TestConditionConstants verifies that the expected condition constant strings
0 commit comments