@@ -89,8 +89,12 @@ func TestRedisDefaultFlow(t *testing.T) {
8989}
9090
9191func TestRedisShutdown (t * testing.T ) {
92+ ctx := context .Background ()
93+ redisC , endpoint := setupRedisContainer (ctx , t )
94+ defer testcontainers .CleanupContainer (t , redisC )
95+
9296 w := NewWorker (
93- WithAddr ( host01 ),
97+ WithConnectionString ( endpoint ),
9498 WithChannel ("test2" ),
9599 )
96100 q , err := queue .NewQueue (
@@ -108,11 +112,14 @@ func TestRedisShutdown(t *testing.T) {
108112}
109113
110114func TestCustomFuncAndWait (t * testing.T ) {
115+ ctx := context .Background ()
116+ redisC , endpoint := setupRedisContainer (ctx , t )
117+ defer testcontainers .CleanupContainer (t , redisC )
111118 m := & mockMessage {
112119 Message : "foo" ,
113120 }
114121 w := NewWorker (
115- WithAddr ( host01 ),
122+ WithConnectionString ( endpoint ),
116123 WithChannel ("test3" ),
117124 WithRunFunc (func (ctx context.Context , m core.QueuedMessage ) error {
118125 time .Sleep (500 * time .Millisecond )
@@ -196,11 +203,14 @@ func TestRedisSentinel(t *testing.T) {
196203}
197204
198205func TestEnqueueJobAfterShutdown (t * testing.T ) {
206+ ctx := context .Background ()
207+ redisC , endpoint := setupRedisContainer (ctx , t )
208+ defer testcontainers .CleanupContainer (t , redisC )
199209 m := mockMessage {
200210 Message : "foo" ,
201211 }
202212 w := NewWorker (
203- WithAddr ( host01 ),
213+ WithConnectionString ( endpoint ),
204214 )
205215 q , err := queue .NewQueue (
206216 queue .WithWorker (w ),
@@ -218,11 +228,14 @@ func TestEnqueueJobAfterShutdown(t *testing.T) {
218228}
219229
220230func TestJobReachTimeout (t * testing.T ) {
231+ ctx := context .Background ()
232+ redisC , endpoint := setupRedisContainer (ctx , t )
233+ defer testcontainers .CleanupContainer (t , redisC )
221234 m := mockMessage {
222235 Message : "foo" ,
223236 }
224237 w := NewWorker (
225- WithAddr ( host01 ),
238+ WithConnectionString ( endpoint ),
226239 WithChannel ("timeout" ),
227240 WithRunFunc (func (ctx context.Context , m core.QueuedMessage ) error {
228241 for {
@@ -255,11 +268,14 @@ func TestJobReachTimeout(t *testing.T) {
255268}
256269
257270func TestCancelJobAfterShutdown (t * testing.T ) {
271+ ctx := context .Background ()
272+ redisC , endpoint := setupRedisContainer (ctx , t )
273+ defer testcontainers .CleanupContainer (t , redisC )
258274 m := mockMessage {
259275 Message : "test" ,
260276 }
261277 w := NewWorker (
262- WithAddr ( host01 ),
278+ WithConnectionString ( endpoint ),
263279 WithChannel ("cancel" ),
264280 WithLogger (queue .NewLogger ()),
265281 WithRunFunc (func (ctx context.Context , m core.QueuedMessage ) error {
@@ -293,11 +309,14 @@ func TestCancelJobAfterShutdown(t *testing.T) {
293309}
294310
295311func TestGoroutineLeak (t * testing.T ) {
312+ ctx := context .Background ()
313+ redisC , endpoint := setupRedisContainer (ctx , t )
314+ defer testcontainers .CleanupContainer (t , redisC )
296315 m := mockMessage {
297316 Message : "foo" ,
298317 }
299318 w := NewWorker (
300- WithAddr ( host01 ),
319+ WithConnectionString ( endpoint ),
301320 WithChannel ("GoroutineLeak" ),
302321 WithLogger (queue .NewEmptyLogger ()),
303322 WithRunFunc (func (ctx context.Context , m core.QueuedMessage ) error {
@@ -338,11 +357,14 @@ func TestGoroutineLeak(t *testing.T) {
338357}
339358
340359func TestGoroutinePanic (t * testing.T ) {
360+ ctx := context .Background ()
361+ redisC , endpoint := setupRedisContainer (ctx , t )
362+ defer testcontainers .CleanupContainer (t , redisC )
341363 m := mockMessage {
342364 Message : "foo" ,
343365 }
344366 w := NewWorker (
345- WithAddr ( host01 ),
367+ WithConnectionString ( endpoint ),
346368 WithChannel ("GoroutinePanic" ),
347369 WithRunFunc (func (ctx context.Context , m core.QueuedMessage ) error {
348370 panic ("missing something" )
0 commit comments