Skip to content

Commit

Permalink
[wtsqs#enqueueMany] Fix empty list error
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-essam committed Jul 20, 2019
1 parent e3ccc93 commit 601c7ad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/wtsqs.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class WTSQS {
*/
async enqueueMany (payloads, { messageGroupId } = {}, sqsOptions = {}) {
if (!(payloads instanceof Array)) throw new InvalidArgument('payloads must be of type array')
if (payloads.length === 0) return

if (payloads.length > 10) {
const chunks = chunk(payloads, 10)
Expand Down
4 changes: 4 additions & 0 deletions test/wtsqs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ describe('WTSQS', () => {
}
})

it('should accept empty list of messages', async () => {
await wtsqs.enqueueMany([])
})

it('should increase queue size by enqueued count', async function () {
await sleep(1000)
const sizeBefore = await wtsqs.size()
Expand Down

0 comments on commit 601c7ad

Please sign in to comment.