@@ -56,7 +56,7 @@ func TestBoundedQueue(t *testing.T) {
5656 startLock .Unlock ()
5757 })))
5858
59- assert .True (t , q .Produce (context .Background (), newStringRequest ("a" )))
59+ assert .NoError (t , q .Offer (context .Background (), newStringRequest ("a" )))
6060
6161 // at this point "a" may or may not have been received by the consumer go-routine
6262 // so let's make sure it has been
@@ -69,10 +69,10 @@ func TestBoundedQueue(t *testing.T) {
6969 })
7070
7171 // produce two more items. The first one should be accepted, but not consumed.
72- assert .True (t , q .Produce (context .Background (), newStringRequest ("b" )))
72+ assert .NoError (t , q .Offer (context .Background (), newStringRequest ("b" )))
7373 assert .Equal (t , 1 , q .Size ())
7474 // the second should be rejected since the queue is full
75- assert .False (t , q .Produce (context .Background (), newStringRequest ("c" )))
75+ assert .ErrorIs (t , q .Offer (context .Background (), newStringRequest ("c" )), ErrQueueIsFull )
7676 assert .Equal (t , 1 , q .Size ())
7777
7878 startLock .Unlock () // unblock consumer
@@ -88,13 +88,13 @@ func TestBoundedQueue(t *testing.T) {
8888 "b" : true ,
8989 }
9090 for _ , item := range []string {"d" , "e" , "f" } {
91- assert .True (t , q .Produce (context .Background (), newStringRequest (item )))
91+ assert .NoError (t , q .Offer (context .Background (), newStringRequest (item )))
9292 expected [item ] = true
9393 consumerState .assertConsumed (expected )
9494 }
9595
9696 assert .NoError (t , q .Shutdown (context .Background ()))
97- assert .False (t , q .Produce (context .Background (), newStringRequest ("x" )), "cannot push to closed queue" )
97+ assert .ErrorIs (t , q .Offer (context .Background (), newStringRequest ("x" )), ErrQueueIsStopped )
9898}
9999
100100// In this test we run a queue with many items and a slow consumer.
@@ -113,20 +113,20 @@ func TestShutdownWhileNotEmpty(t *testing.T) {
113113 time .Sleep (1 * time .Second )
114114 })))
115115
116- q . Produce (context .Background (), newStringRequest ("a" ))
117- q . Produce (context .Background (), newStringRequest ("b" ))
118- q . Produce (context .Background (), newStringRequest ("c" ))
119- q . Produce (context .Background (), newStringRequest ("d" ))
120- q . Produce (context .Background (), newStringRequest ("e" ))
121- q . Produce (context .Background (), newStringRequest ("f" ))
122- q . Produce (context .Background (), newStringRequest ("g" ))
123- q . Produce (context .Background (), newStringRequest ("h" ))
124- q . Produce (context .Background (), newStringRequest ("i" ))
125- q . Produce (context .Background (), newStringRequest ("j" ))
116+ assert . NoError ( t , q . Offer (context .Background (), newStringRequest ("a" ) ))
117+ assert . NoError ( t , q . Offer (context .Background (), newStringRequest ("b" ) ))
118+ assert . NoError ( t , q . Offer (context .Background (), newStringRequest ("c" ) ))
119+ assert . NoError ( t , q . Offer (context .Background (), newStringRequest ("d" ) ))
120+ assert . NoError ( t , q . Offer (context .Background (), newStringRequest ("e" ) ))
121+ assert . NoError ( t , q . Offer (context .Background (), newStringRequest ("f" ) ))
122+ assert . NoError ( t , q . Offer (context .Background (), newStringRequest ("g" ) ))
123+ assert . NoError ( t , q . Offer (context .Background (), newStringRequest ("h" ) ))
124+ assert . NoError ( t , q . Offer (context .Background (), newStringRequest ("i" ) ))
125+ assert . NoError ( t , q . Offer (context .Background (), newStringRequest ("j" ) ))
126126
127127 assert .NoError (t , q .Shutdown (context .Background ()))
128128
129- assert .False (t , q .Produce (context .Background (), newStringRequest ("x" )), "cannot push to closed queue" )
129+ assert .ErrorIs (t , q .Offer (context .Background (), newStringRequest ("x" )), ErrQueueIsStopped )
130130 consumerState .assertConsumed (map [string ]bool {
131131 "a" : true ,
132132 "b" : true ,
@@ -193,7 +193,7 @@ func queueUsage(b *testing.B, capacity int, numConsumers int, numberOfItems int)
193193 }))
194194 require .NoError (b , err )
195195 for j := 0 ; j < numberOfItems ; j ++ {
196- q . Produce (context .Background (), newStringRequest (fmt .Sprintf ("%d" , j )))
196+ _ = q . Offer (context .Background (), newStringRequest (fmt .Sprintf ("%d" , j )))
197197 }
198198 assert .NoError (b , q .Shutdown (context .Background ()))
199199 }
@@ -250,7 +250,7 @@ func TestZeroSizeWithConsumers(t *testing.T) {
250250 err := q .Start (context .Background (), componenttest .NewNopHost (), newNopQueueSettings (func (item any ) {}))
251251 assert .NoError (t , err )
252252
253- assert .True (t , q .Produce (context .Background (), newStringRequest ("a" ))) // in process
253+ assert .NoError (t , q .Offer (context .Background (), newStringRequest ("a" ))) // in process
254254
255255 assert .NoError (t , q .Shutdown (context .Background ()))
256256}
@@ -261,7 +261,7 @@ func TestZeroSizeNoConsumers(t *testing.T) {
261261 err := q .Start (context .Background (), componenttest .NewNopHost (), newNopQueueSettings (func (item any ) {}))
262262 assert .NoError (t , err )
263263
264- assert .False (t , q .Produce (context .Background (), newStringRequest ("a" ))) // in process
264+ assert .ErrorIs (t , q .Offer (context .Background (), newStringRequest ("a" )), ErrQueueIsFull ) // in process
265265
266266 assert .NoError (t , q .Shutdown (context .Background ()))
267267}
0 commit comments