File tree Expand file tree Collapse file tree 1 file changed +5
-18
lines changed
pkg/controller/priorityqueue Expand file tree Collapse file tree 1 file changed +5
-18
lines changed Original file line number Diff line number Diff line change @@ -185,24 +185,15 @@ var _ = Describe("Controllerworkqueue", func() {
185185 })
186186
187187 It ("returns high priority item that became ready before low priority item" , func () {
188- q , metrics := newQueue ()
188+ q , metrics , forwardQueueTimeBy := newQueueWithTimeForwarder ()
189189 defer q .ShutDown ()
190190
191- now := time .Now ().Round (time .Second )
192- nowLock := sync.Mutex {}
193- tick := make (chan time.Time )
194191 tickSetup := make (chan any )
195-
196- cwq := q .(* priorityqueue [string ])
197- cwq .now = func () time.Time {
198- nowLock .Lock ()
199- defer nowLock .Unlock ()
200- return now
201- }
202- cwq .tick = func (d time.Duration ) <- chan time.Time {
192+ originalTick := q .tick
193+ q .tick = func (d time.Duration ) <- chan time.Time {
203194 Expect (d ).To (Equal (time .Second ))
204195 close (tickSetup )
205- return tick
196+ return originalTick ( d )
206197 }
207198
208199 lowPriority := - 100
@@ -212,11 +203,7 @@ var _ = Describe("Controllerworkqueue", func() {
212203
213204 Eventually (tickSetup ).Should (BeClosed ())
214205
215- nowLock .Lock ()
216- now = now .Add (time .Second )
217- nowLock .Unlock ()
218- tick <- now
219-
206+ forwardQueueTimeBy (1 * time .Second )
220207 key , prio , _ := q .GetWithPriority ()
221208
222209 Expect (key ).To (Equal ("prio" ))
You can’t perform that action at this time.
0 commit comments