@@ -184,13 +184,14 @@ var _ = Describe("Controllerworkqueue", func() {
184184 Expect (metrics .retries ["test" ]).To (Equal (1 ))
185185 })
186186
187- It ("returns high priority item that became ready before low priority items " , func () {
187+ It ("returns high priority item that became ready before low priority item " , func () {
188188 q , metrics := newQueue ()
189189 defer q .ShutDown ()
190190
191191 now := time .Now ().Round (time .Second )
192192 nowLock := sync.Mutex {}
193193 tick := make (chan time.Time )
194+ tickSetup := make (chan any )
194195
195196 cwq := q .(* priorityqueue [string ])
196197 cwq .now = func () time.Time {
@@ -200,47 +201,28 @@ var _ = Describe("Controllerworkqueue", func() {
200201 }
201202 cwq .tick = func (d time.Duration ) <- chan time.Time {
202203 Expect (d ).To (Equal (time .Second ))
204+ close (tickSetup )
203205 return tick
204206 }
205207
206- retrievedItem := make (chan any )
207- getNext := make (chan any )
208-
209- go func () {
210- defer GinkgoRecover ()
211- defer close (retrievedItem )
212-
213- key , prio , _ := q .GetWithPriority ()
214- Expect (key ).To (Equal ("foo" ))
215- Expect (prio ).To (Equal (- 100 ))
216-
217- retrievedItem <- nil
218- <- getNext
219-
220- key , prio , _ = q .GetWithPriority ()
221- Expect (key ).To (Equal ("prio" ))
222- Expect (prio ).To (Equal (0 ))
223- }()
224-
225208 lowPriority := - 100
226209 highPriority := 0
227210 q .AddWithOpts (AddOpts {After : 0 , Priority : & lowPriority }, "foo" )
228- q .AddWithOpts (AddOpts {After : 0 , Priority : & lowPriority }, "bar" )
229211 q .AddWithOpts (AddOpts {After : time .Second , Priority : & highPriority }, "prio" )
230212
231- <- retrievedItem
213+ Eventually ( tickSetup ). Should ( BeClosed ())
232214
233215 nowLock .Lock ()
234216 now = now .Add (time .Second )
235217 nowLock .Unlock ()
236218 tick <- now
237- getNext <- nil
238219
239- Eventually (retrievedItem ).Should (BeClosed ())
240- close (getNext )
220+ key , prio , _ := q .GetWithPriority ()
241221
222+ Expect (key ).To (Equal ("prio" ))
223+ Expect (prio ).To (Equal (0 ))
242224 Expect (metrics .depth ["test" ]).To (Equal (map [int ]int {- 100 : 1 , 0 : 0 }))
243- Expect (metrics .adds ["test" ]).To (Equal (3 ))
225+ Expect (metrics .adds ["test" ]).To (Equal (2 ))
244226 Expect (metrics .retries ["test" ]).To (Equal (1 ))
245227 })
246228
0 commit comments