@@ -146,9 +146,10 @@ func TestSQSRetries(t *testing.T) {
146
146
config .WithCredentialsProvider (credentials .NewStaticCredentialsProvider ("xxxxx" , "xxxxx" , "xxxxx" )),
147
147
)
148
148
require .NoError (t , err )
149
-
149
+ url , err := service .NewInterpolatedString ("http://foo.example.com" )
150
+ require .NoError (t , err )
150
151
w , err := newSQSWriter (sqsoConfig {
151
- URL : "http://foo.example.com" ,
152
+ URL : url ,
152
153
backoffCtor : func () backoff.BackOff {
153
154
return backoff .NewExponentialBackOff ()
154
155
},
@@ -218,8 +219,10 @@ func TestSQSSendLimit(t *testing.T) {
218
219
)
219
220
require .NoError (t , err )
220
221
222
+ url , err := service .NewInterpolatedString ("http://foo.example.com" )
223
+ require .NoError (t , err )
221
224
w , err := newSQSWriter (sqsoConfig {
222
- URL : "http://foo.example.com" ,
225
+ URL : url ,
223
226
backoffCtor : func () backoff.BackOff {
224
227
return backoff .NewExponentialBackOff ()
225
228
},
@@ -281,3 +284,94 @@ func TestSQSSendLimit(t *testing.T) {
281
284
},
282
285
}, in )
283
286
}
287
+
288
+ func TestSQSMultipleQueues (t * testing.T ) {
289
+ tCtx := context .Background ()
290
+
291
+ conf , err := config .LoadDefaultConfig (context .Background (),
292
+ config .WithCredentialsProvider (credentials .NewStaticCredentialsProvider ("xxxxx" , "xxxxx" , "xxxxx" )),
293
+ )
294
+ require .NoError (t , err )
295
+
296
+ url , err := service .NewInterpolatedString ("http://${!counter()%2}.example.com" )
297
+ require .NoError (t , err )
298
+ w , err := newSQSWriter (sqsoConfig {
299
+ URL : url ,
300
+ backoffCtor : func () backoff.BackOff {
301
+ return backoff .NewExponentialBackOff ()
302
+ },
303
+ aconf : conf ,
304
+ }, service .MockResources ())
305
+ require .NoError (t , err )
306
+
307
+ in := map [string ][]inEntries {}
308
+ sendCalls := 0
309
+ w .sqs = & mockSqs {
310
+ fn : func (smbi * sqs.SendMessageBatchInput ) (* sqs.SendMessageBatchOutput , error ) {
311
+ var e inEntries
312
+ for _ , entry := range smbi .Entries {
313
+ e = append (e , inMsg {
314
+ id : * entry .Id ,
315
+ content : * entry .MessageBody ,
316
+ })
317
+ }
318
+ if smbi .QueueUrl == nil {
319
+ return nil , errors .New ("nil queue URL" )
320
+ }
321
+ in [* smbi .QueueUrl ] = append (in [* smbi .QueueUrl ], e )
322
+ sendCalls ++
323
+ return & sqs.SendMessageBatchOutput {}, nil
324
+ },
325
+ }
326
+
327
+ inMsg := service.MessageBatch {}
328
+ for i := 0 ; i < 30 ; i ++ {
329
+ inMsg = append (inMsg , service .NewMessage ([]byte (fmt .Sprintf ("hello world %v" , i + 1 ))))
330
+ }
331
+ require .NoError (t , w .WriteBatch (tCtx , inMsg ))
332
+
333
+ assert .Equal (t , map [string ][]inEntries {
334
+ "http://0.example.com" : {
335
+ {
336
+ {id : "1" , content : "hello world 2" },
337
+ {id : "3" , content : "hello world 4" },
338
+ {id : "5" , content : "hello world 6" },
339
+ {id : "7" , content : "hello world 8" },
340
+ {id : "9" , content : "hello world 10" },
341
+ {id : "11" , content : "hello world 12" },
342
+ {id : "13" , content : "hello world 14" },
343
+ {id : "15" , content : "hello world 16" },
344
+ {id : "17" , content : "hello world 18" },
345
+ {id : "19" , content : "hello world 20" },
346
+ },
347
+ {
348
+ {id : "21" , content : "hello world 22" },
349
+ {id : "23" , content : "hello world 24" },
350
+ {id : "25" , content : "hello world 26" },
351
+ {id : "27" , content : "hello world 28" },
352
+ {id : "29" , content : "hello world 30" },
353
+ },
354
+ },
355
+ "http://1.example.com" : {
356
+ {
357
+ {id : "0" , content : "hello world 1" },
358
+ {id : "2" , content : "hello world 3" },
359
+ {id : "4" , content : "hello world 5" },
360
+ {id : "6" , content : "hello world 7" },
361
+ {id : "8" , content : "hello world 9" },
362
+ {id : "10" , content : "hello world 11" },
363
+ {id : "12" , content : "hello world 13" },
364
+ {id : "14" , content : "hello world 15" },
365
+ {id : "16" , content : "hello world 17" },
366
+ {id : "18" , content : "hello world 19" },
367
+ },
368
+ {
369
+ {id : "20" , content : "hello world 21" },
370
+ {id : "22" , content : "hello world 23" },
371
+ {id : "24" , content : "hello world 25" },
372
+ {id : "26" , content : "hello world 27" },
373
+ {id : "28" , content : "hello world 29" },
374
+ },
375
+ },
376
+ }, in )
377
+ }
0 commit comments