@@ -5,11 +5,13 @@ import (
5
5
"encoding/json"
6
6
"reflect"
7
7
"testing"
8
+ "time"
8
9
9
10
"github.com/openshift/library-go/pkg/operator/events"
10
11
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
11
12
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
12
13
"k8s.io/client-go/tools/cache"
14
+ clocktesting "k8s.io/utils/clock/testing"
13
15
14
16
configv1 "github.com/openshift/api/config/v1"
15
17
configlistersv1 "github.com/openshift/client-go/config/listers/config/v1"
@@ -135,7 +137,7 @@ func TestObserveImageConfig(t *testing.T) {
135
137
ImageConfigLister : configlistersv1 .NewImageLister (indexer ),
136
138
}
137
139
138
- result , errs := ObserveInternalRegistryHostname (listers , events .NewInMemoryRecorder ("" ), map [string ]interface {}{})
140
+ result , errs := ObserveInternalRegistryHostname (listers , events .NewInMemoryRecorder ("" , clocktesting . NewFakePassiveClock ( time . Now ()) ), map [string ]interface {}{})
139
141
if len (errs ) != 0 {
140
142
t .Fatalf ("unexpected error: %v" , errs )
141
143
}
@@ -149,15 +151,15 @@ func TestObserveImageConfig(t *testing.T) {
149
151
150
152
// When the cache is not synced, the result should be the previously observed
151
153
// configuration.
152
- newResult , errs := ObserveInternalRegistryHostname (unsyncedlisters , events .NewInMemoryRecorder ("test" ), result )
154
+ newResult , errs := ObserveInternalRegistryHostname (unsyncedlisters , events .NewInMemoryRecorder ("test" , clocktesting . NewFakePassiveClock ( time . Now ()) ), result )
153
155
if len (errs ) != 0 {
154
156
t .Fatalf ("unexpected error: %v" , errs )
155
157
}
156
158
if ! reflect .DeepEqual (result , newResult ) {
157
159
t .Errorf ("got: \n %#v\n expected: \n %#v" , newResult , result )
158
160
}
159
161
160
- result , errs = ObserveExternalRegistryHostnames (listers , events .NewInMemoryRecorder ("" ), map [string ]interface {}{})
162
+ result , errs = ObserveExternalRegistryHostnames (listers , events .NewInMemoryRecorder ("" , clocktesting . NewFakePassiveClock ( time . Now ()) ), map [string ]interface {}{})
161
163
if len (errs ) != 0 {
162
164
t .Fatalf ("unexpected error: %v" , errs )
163
165
}
@@ -176,15 +178,15 @@ func TestObserveImageConfig(t *testing.T) {
176
178
177
179
// When the cache is not synced, the result should be the previously observed
178
180
// configuration.
179
- newResult , errs = ObserveExternalRegistryHostnames (unsyncedlisters , events .NewInMemoryRecorder ("" ), result )
181
+ newResult , errs = ObserveExternalRegistryHostnames (unsyncedlisters , events .NewInMemoryRecorder ("" , clocktesting . NewFakePassiveClock ( time . Now ()) ), result )
180
182
if len (errs ) != 0 {
181
183
t .Fatalf ("unexpected error: %v" , errs )
182
184
}
183
185
if ! reflect .DeepEqual (result , newResult ) {
184
186
t .Errorf ("got: \n %#v\n expected: \n %#v" , newResult , result )
185
187
}
186
188
187
- result , errs = ObserveAllowedRegistriesForImport (listers , events .NewInMemoryRecorder ("" ), map [string ]interface {}{})
189
+ result , errs = ObserveAllowedRegistriesForImport (listers , events .NewInMemoryRecorder ("" , clocktesting . NewFakePassiveClock ( time . Now ()) ), map [string ]interface {}{})
188
190
if len (errs ) != 0 {
189
191
t .Fatalf ("unexpected error: %v" , errs )
190
192
}
@@ -203,7 +205,7 @@ func TestObserveImageConfig(t *testing.T) {
203
205
204
206
// When the cache is not synced, the result should be the previously observed
205
207
// configuration.
206
- newResult , errs = ObserveAllowedRegistriesForImport (unsyncedlisters , events .NewInMemoryRecorder ("" ), result )
208
+ newResult , errs = ObserveAllowedRegistriesForImport (unsyncedlisters , events .NewInMemoryRecorder ("" , clocktesting . NewFakePassiveClock ( time . Now ()) ), result )
207
209
if len (errs ) != 0 {
208
210
t .Fatalf ("unexpected error: %v" , errs )
209
211
}
@@ -258,7 +260,7 @@ func TestObserveImageConfigImageStreamImportMode(t *testing.T) {
258
260
ImageConfigLister : configlistersv1 .NewImageLister (indexer ),
259
261
}
260
262
261
- result , errs := ObserveImagestreamImportMode (listers , events .NewInMemoryRecorder ("" ), map [string ]interface {}{})
263
+ result , errs := ObserveImagestreamImportMode (listers , events .NewInMemoryRecorder ("" , clocktesting . NewFakePassiveClock ( time . Now ()) ), map [string ]interface {}{})
262
264
if len (errs ) != 0 {
263
265
t .Fatalf ("unexpected error: %v" , errs )
264
266
}
@@ -272,7 +274,7 @@ func TestObserveImageConfigImageStreamImportMode(t *testing.T) {
272
274
273
275
// When the cache is not synced, the result should be the previously observed
274
276
// configuration.
275
- newResult , errs := ObserveImagestreamImportMode (unsyncedlisters , events .NewInMemoryRecorder ("test" ), result )
277
+ newResult , errs := ObserveImagestreamImportMode (unsyncedlisters , events .NewInMemoryRecorder ("test" , clocktesting . NewFakePassiveClock ( time . Now ()) ), result )
276
278
if len (errs ) != 0 {
277
279
t .Fatalf ("unexpected error: %v" , errs )
278
280
}
0 commit comments