@@ -24,6 +24,7 @@ func TestClusterVersionOperatorConfiguration_sync(t *testing.T) {
24
24
expectedConfig operatorv1alpha1.ClusterVersionOperator
25
25
internalConfig configuration
26
26
expectedInternalConfig configuration
27
+ handlerFunctionCalled bool
27
28
}{
28
29
{
29
30
name : "first sync run correctly updates the status" ,
@@ -54,6 +55,7 @@ func TestClusterVersionOperatorConfiguration_sync(t *testing.T) {
54
55
desiredLogLevel : operatorv1 .Normal ,
55
56
lastObservedGeneration : 1 ,
56
57
},
58
+ handlerFunctionCalled : true ,
57
59
},
58
60
{
59
61
name : "sync updates observed generation correctly" ,
@@ -87,6 +89,7 @@ func TestClusterVersionOperatorConfiguration_sync(t *testing.T) {
87
89
desiredLogLevel : operatorv1 .Normal ,
88
90
lastObservedGeneration : 3 ,
89
91
},
92
+ handlerFunctionCalled : true ,
90
93
},
91
94
{
92
95
name : "sync updates desired log level correctly" ,
@@ -120,6 +123,7 @@ func TestClusterVersionOperatorConfiguration_sync(t *testing.T) {
120
123
desiredLogLevel : operatorv1 .Trace ,
121
124
lastObservedGeneration : 4 ,
122
125
},
126
+ handlerFunctionCalled : true ,
123
127
},
124
128
{
125
129
name : "number of not observed generations does not impact sync" ,
@@ -153,6 +157,7 @@ func TestClusterVersionOperatorConfiguration_sync(t *testing.T) {
153
157
desiredLogLevel : operatorv1 .TraceAll ,
154
158
lastObservedGeneration : 40 ,
155
159
},
160
+ handlerFunctionCalled : true ,
156
161
},
157
162
}
158
163
for _ , tt := range tests {
@@ -166,6 +171,12 @@ func TestClusterVersionOperatorConfiguration_sync(t *testing.T) {
166
171
167
172
configController := NewClusterVersionOperatorConfiguration (client , factory )
168
173
174
+ called := false
175
+ configController .handler = func (_ configuration ) error {
176
+ called = true
177
+ return nil
178
+ }
179
+
169
180
ctx , cancelFunc := context .WithDeadline (context .Background (), time .Now ().Add (time .Minute ))
170
181
171
182
if err := configController .Start (ctx ); err != nil {
@@ -194,6 +205,10 @@ func TestClusterVersionOperatorConfiguration_sync(t *testing.T) {
194
205
t .Errorf ("unexpected config (-want, +got) = %v" , diff )
195
206
}
196
207
208
+ if tt .handlerFunctionCalled != called {
209
+ t .Errorf ("unexpected handler function execution; wanted=%v, got=%v" , tt .handlerFunctionCalled , called )
210
+ }
211
+
197
212
// Shutdown created resources
198
213
cancelFunc ()
199
214
})
0 commit comments