@@ -89,8 +89,12 @@ func TestRedisDefaultFlow(t *testing.T) {
89
89
}
90
90
91
91
func TestRedisShutdown (t * testing.T ) {
92
+ ctx := context .Background ()
93
+ redisC , endpoint := setupRedisContainer (ctx , t )
94
+ defer testcontainers .CleanupContainer (t , redisC )
95
+
92
96
w := NewWorker (
93
- WithAddr ( host01 ),
97
+ WithConnectionString ( endpoint ),
94
98
WithChannel ("test2" ),
95
99
)
96
100
q , err := queue .NewQueue (
@@ -108,11 +112,14 @@ func TestRedisShutdown(t *testing.T) {
108
112
}
109
113
110
114
func TestCustomFuncAndWait (t * testing.T ) {
115
+ ctx := context .Background ()
116
+ redisC , endpoint := setupRedisContainer (ctx , t )
117
+ defer testcontainers .CleanupContainer (t , redisC )
111
118
m := & mockMessage {
112
119
Message : "foo" ,
113
120
}
114
121
w := NewWorker (
115
- WithAddr ( host01 ),
122
+ WithConnectionString ( endpoint ),
116
123
WithChannel ("test3" ),
117
124
WithRunFunc (func (ctx context.Context , m core.QueuedMessage ) error {
118
125
time .Sleep (500 * time .Millisecond )
@@ -196,11 +203,14 @@ func TestRedisSentinel(t *testing.T) {
196
203
}
197
204
198
205
func TestEnqueueJobAfterShutdown (t * testing.T ) {
206
+ ctx := context .Background ()
207
+ redisC , endpoint := setupRedisContainer (ctx , t )
208
+ defer testcontainers .CleanupContainer (t , redisC )
199
209
m := mockMessage {
200
210
Message : "foo" ,
201
211
}
202
212
w := NewWorker (
203
- WithAddr ( host01 ),
213
+ WithConnectionString ( endpoint ),
204
214
)
205
215
q , err := queue .NewQueue (
206
216
queue .WithWorker (w ),
@@ -218,11 +228,14 @@ func TestEnqueueJobAfterShutdown(t *testing.T) {
218
228
}
219
229
220
230
func TestJobReachTimeout (t * testing.T ) {
231
+ ctx := context .Background ()
232
+ redisC , endpoint := setupRedisContainer (ctx , t )
233
+ defer testcontainers .CleanupContainer (t , redisC )
221
234
m := mockMessage {
222
235
Message : "foo" ,
223
236
}
224
237
w := NewWorker (
225
- WithAddr ( host01 ),
238
+ WithConnectionString ( endpoint ),
226
239
WithChannel ("timeout" ),
227
240
WithRunFunc (func (ctx context.Context , m core.QueuedMessage ) error {
228
241
for {
@@ -255,11 +268,14 @@ func TestJobReachTimeout(t *testing.T) {
255
268
}
256
269
257
270
func TestCancelJobAfterShutdown (t * testing.T ) {
271
+ ctx := context .Background ()
272
+ redisC , endpoint := setupRedisContainer (ctx , t )
273
+ defer testcontainers .CleanupContainer (t , redisC )
258
274
m := mockMessage {
259
275
Message : "test" ,
260
276
}
261
277
w := NewWorker (
262
- WithAddr ( host01 ),
278
+ WithConnectionString ( endpoint ),
263
279
WithChannel ("cancel" ),
264
280
WithLogger (queue .NewLogger ()),
265
281
WithRunFunc (func (ctx context.Context , m core.QueuedMessage ) error {
@@ -293,11 +309,14 @@ func TestCancelJobAfterShutdown(t *testing.T) {
293
309
}
294
310
295
311
func TestGoroutineLeak (t * testing.T ) {
312
+ ctx := context .Background ()
313
+ redisC , endpoint := setupRedisContainer (ctx , t )
314
+ defer testcontainers .CleanupContainer (t , redisC )
296
315
m := mockMessage {
297
316
Message : "foo" ,
298
317
}
299
318
w := NewWorker (
300
- WithAddr ( host01 ),
319
+ WithConnectionString ( endpoint ),
301
320
WithChannel ("GoroutineLeak" ),
302
321
WithLogger (queue .NewEmptyLogger ()),
303
322
WithRunFunc (func (ctx context.Context , m core.QueuedMessage ) error {
@@ -338,11 +357,14 @@ func TestGoroutineLeak(t *testing.T) {
338
357
}
339
358
340
359
func TestGoroutinePanic (t * testing.T ) {
360
+ ctx := context .Background ()
361
+ redisC , endpoint := setupRedisContainer (ctx , t )
362
+ defer testcontainers .CleanupContainer (t , redisC )
341
363
m := mockMessage {
342
364
Message : "foo" ,
343
365
}
344
366
w := NewWorker (
345
- WithAddr ( host01 ),
367
+ WithConnectionString ( endpoint ),
346
368
WithChannel ("GoroutinePanic" ),
347
369
WithRunFunc (func (ctx context.Context , m core.QueuedMessage ) error {
348
370
panic ("missing something" )
0 commit comments