@@ -140,6 +140,7 @@ func TestDetectsOpenShiftRouteSuffix(t *testing.T) {
140
140
}
141
141
142
142
func TestSyncConfigFromIgnoresOtherConfigInOtherNamespaces (t * testing.T ) {
143
+ setupForTest (t )
143
144
internalConfig = DefaultConfig .DeepCopy ()
144
145
config := buildConfig (& v1alpha1.OperatorConfiguration {
145
146
Workspace : & v1alpha1.WorkspaceConfig {
@@ -152,6 +153,7 @@ func TestSyncConfigFromIgnoresOtherConfigInOtherNamespaces(t *testing.T) {
152
153
}
153
154
154
155
func TestSyncConfigFromIgnoresOtherConfigWithOtherName (t * testing.T ) {
156
+ setupForTest (t )
155
157
internalConfig = DefaultConfig .DeepCopy ()
156
158
config := buildConfig (& v1alpha1.OperatorConfiguration {
157
159
Workspace : & v1alpha1.WorkspaceConfig {
@@ -164,6 +166,7 @@ func TestSyncConfigFromIgnoresOtherConfigWithOtherName(t *testing.T) {
164
166
}
165
167
166
168
func TestSyncConfigDoesNotChangeDefaults (t * testing.T ) {
169
+ setupForTest (t )
167
170
oldDefaultConfig := DefaultConfig .DeepCopy ()
168
171
internalConfig = DefaultConfig .DeepCopy ()
169
172
config := buildConfig (& v1alpha1.OperatorConfiguration {
@@ -181,6 +184,38 @@ func TestSyncConfigDoesNotChangeDefaults(t *testing.T) {
181
184
assert .Equal (t , DefaultConfig , oldDefaultConfig )
182
185
}
183
186
187
+ func TestSyncConfigDoesNotEraseClusterRoutingSuffix (t * testing.T ) {
188
+ setupForTest (t )
189
+ infrastructure .InitializeForTesting (infrastructure .OpenShiftv4 )
190
+ testRoute := & routev1.Route {
191
+ ObjectMeta : metav1.ObjectMeta {
192
+ Name : openShiftTestRouteName ,
193
+ Namespace : testNamespace ,
194
+ },
195
+ Spec : routev1.RouteSpec {
196
+ Host : fmt .Sprintf ("%s-%s.test-host" , openShiftTestRouteName , testNamespace ),
197
+ },
198
+ }
199
+ client := fake .NewClientBuilder ().WithScheme (scheme ).WithObjects (testRoute ).Build ()
200
+ err := SetupControllerConfig (client )
201
+ if ! assert .NoError (t , err , "Should not return error" ) {
202
+ return
203
+ }
204
+ assert .Equal (t , "test-host" , Routing .ClusterHostSuffix , "Should get clusterHostSuffix from route on OpenShift" )
205
+ syncConfigFrom (buildConfig (& v1alpha1.OperatorConfiguration {
206
+ Routing : & v1alpha1.RoutingConfig {
207
+ DefaultRoutingClass : "test-routingClass" ,
208
+ },
209
+ Workspace : & v1alpha1.WorkspaceConfig {
210
+ ImagePullPolicy : "IfNotPresent" ,
211
+ },
212
+ }))
213
+ if ! assert .NoError (t , err , "Should not return error" ) {
214
+ return
215
+ }
216
+ assert .Equal (t , "test-host" , Routing .ClusterHostSuffix , "clusterHostSuffix should persist after an update" )
217
+ }
218
+
184
219
func TestMergeConfigLooksAtAllFields (t * testing.T ) {
185
220
f := fuzz .New ().NilChance (0 )
186
221
expectedConfig := & v1alpha1.OperatorConfiguration {}
0 commit comments