@@ -22,8 +22,8 @@ func TestClusterVersionOperatorConfiguration_sync(t *testing.T) {
22
22
name string
23
23
config operatorv1alpha1.ClusterVersionOperator
24
24
expectedConfig operatorv1alpha1.ClusterVersionOperator
25
- internalConfig ClusterVersionOperatorConfiguration
26
- expectedInternalConfig ClusterVersionOperatorConfiguration
25
+ internalConfig configuration
26
+ expectedInternalConfig configuration
27
27
}{
28
28
{
29
29
name : "first sync run correctly updates the status" ,
@@ -46,11 +46,11 @@ func TestClusterVersionOperatorConfiguration_sync(t *testing.T) {
46
46
ObservedGeneration : 1 ,
47
47
},
48
48
},
49
- internalConfig : ClusterVersionOperatorConfiguration {
49
+ internalConfig : configuration {
50
50
desiredLogLevel : operatorv1 .Normal ,
51
51
lastObservedGeneration : 0 ,
52
52
},
53
- expectedInternalConfig : ClusterVersionOperatorConfiguration {
53
+ expectedInternalConfig : configuration {
54
54
desiredLogLevel : operatorv1 .Normal ,
55
55
lastObservedGeneration : 1 ,
56
56
},
@@ -79,11 +79,11 @@ func TestClusterVersionOperatorConfiguration_sync(t *testing.T) {
79
79
ObservedGeneration : 3 ,
80
80
},
81
81
},
82
- internalConfig : ClusterVersionOperatorConfiguration {
82
+ internalConfig : configuration {
83
83
desiredLogLevel : operatorv1 .Normal ,
84
84
lastObservedGeneration : 2 ,
85
85
},
86
- expectedInternalConfig : ClusterVersionOperatorConfiguration {
86
+ expectedInternalConfig : configuration {
87
87
desiredLogLevel : operatorv1 .Normal ,
88
88
lastObservedGeneration : 3 ,
89
89
},
@@ -112,11 +112,11 @@ func TestClusterVersionOperatorConfiguration_sync(t *testing.T) {
112
112
ObservedGeneration : 4 ,
113
113
},
114
114
},
115
- internalConfig : ClusterVersionOperatorConfiguration {
115
+ internalConfig : configuration {
116
116
desiredLogLevel : operatorv1 .Normal ,
117
117
lastObservedGeneration : 3 ,
118
118
},
119
- expectedInternalConfig : ClusterVersionOperatorConfiguration {
119
+ expectedInternalConfig : configuration {
120
120
desiredLogLevel : operatorv1 .Trace ,
121
121
lastObservedGeneration : 4 ,
122
122
},
@@ -145,11 +145,11 @@ func TestClusterVersionOperatorConfiguration_sync(t *testing.T) {
145
145
ObservedGeneration : 40 ,
146
146
},
147
147
},
148
- internalConfig : ClusterVersionOperatorConfiguration {
148
+ internalConfig : configuration {
149
149
desiredLogLevel : operatorv1 .Normal ,
150
150
lastObservedGeneration : 3 ,
151
151
},
152
- expectedInternalConfig : ClusterVersionOperatorConfiguration {
152
+ expectedInternalConfig : configuration {
153
153
desiredLogLevel : operatorv1 .TraceAll ,
154
154
lastObservedGeneration : 40 ,
155
155
},
@@ -158,24 +158,35 @@ func TestClusterVersionOperatorConfiguration_sync(t *testing.T) {
158
158
for _ , tt := range tests {
159
159
t .Run (tt .name , func (t * testing.T ) {
160
160
// Initialize testing logic
161
+ tt .config .Name = ClusterVersionOperatorConfigurationName
162
+ tt .expectedConfig .Name = ClusterVersionOperatorConfigurationName
163
+
161
164
client := operatorclientsetfake .NewClientset (& tt .config )
162
- tt .internalConfig .client = client .OperatorV1alpha1 ().ClusterVersionOperators ()
165
+ factory := operatorexternalversions .NewSharedInformerFactoryWithOptions (client , time .Minute )
166
+
167
+ configController := NewClusterVersionOperatorConfiguration (client , factory )
168
+
163
169
ctx , cancelFunc := context .WithDeadline (context .Background (), time .Now ().Add (time .Minute ))
164
170
171
+ if err := configController .Start (ctx ); err != nil {
172
+ t .Errorf ("unexpected error %v" , err )
173
+ }
174
+ configController .configuration = tt .internalConfig
175
+
165
176
// Run tested functionality
166
- if err := tt . internalConfig . sync (ctx , & tt . config ); err != nil {
177
+ if err := configController . Sync (ctx , "key" ); err != nil {
167
178
t .Errorf ("unexpected error %v" , err )
168
179
}
169
180
170
181
// Verify results
171
- if tt . internalConfig .lastObservedGeneration != tt .expectedInternalConfig .lastObservedGeneration {
172
- t .Errorf ("unexpected 'lastObservedGeneration' value; wanted=%v, got=%v" , tt .expectedInternalConfig .lastObservedGeneration , tt . internalConfig .lastObservedGeneration )
182
+ if configController . configuration .lastObservedGeneration != tt .expectedInternalConfig .lastObservedGeneration {
183
+ t .Errorf ("unexpected 'lastObservedGeneration' value; wanted=%v, got=%v" , tt .expectedInternalConfig .lastObservedGeneration , configController . configuration .lastObservedGeneration )
173
184
}
174
- if tt . internalConfig .desiredLogLevel != tt .expectedInternalConfig .desiredLogLevel {
175
- t .Errorf ("unexpected 'desiredLogLevel' value; wanted=%v, got=%v" , tt .expectedInternalConfig .desiredLogLevel , tt . internalConfig .desiredLogLevel )
185
+ if configController . configuration .desiredLogLevel != tt .expectedInternalConfig .desiredLogLevel {
186
+ t .Errorf ("unexpected 'desiredLogLevel' value; wanted=%v, got=%v" , tt .expectedInternalConfig .desiredLogLevel , configController . configuration .desiredLogLevel )
176
187
}
177
188
178
- config , err := client .OperatorV1alpha1 ().ClusterVersionOperators ().Get (ctx , "" , metav1.GetOptions {})
189
+ config , err := client .OperatorV1alpha1 ().ClusterVersionOperators ().Get (ctx , ClusterVersionOperatorConfigurationName , metav1.GetOptions {})
179
190
if err != nil {
180
191
t .Errorf ("unexpected error %v" , err )
181
192
}
0 commit comments