Skip to content

Commit cb7bd1a

Browse files
committed
Throw NJS-005 for queue.deqMany(0)
1 parent eccd25c commit cb7bd1a

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/njsAqQueue.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,8 @@ static bool njsAqQueue_deqManyProcessArgs(njsBaton *baton,
396396
{
397397
if (!njsUtils_getUnsignedIntArg(env, args, 0, &baton->numMsgProps))
398398
return false;
399+
if (baton->numMsgProps == 0)
400+
return njsUtils_throwError(env, errInvalidParameterValue, 1);
399401

400402
return true;
401403
}

test/aq3.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,17 @@ describe('219. aq3.js', function() {
161161
}
162162
}); // 219.4
163163

164-
it.skip('219.5 Negative - Set "maxMessages" argument to be 0', async () => {
164+
it('219.5 Negative - Set "maxMessages" argument to be 0', async () => {
165165
try {
166166
const queue = await conn.getQueue(rawQueueName);
167-
const messages = await queue.deqMany(0);
168167

168+
testsUtil.assertThrowsAsync(
169+
async () => {
170+
const messages = await queue.deqMany(0);
171+
should.not.exist(messages);
172+
},
173+
/NJS-005/
174+
);
169175
} catch (err) {
170176
should.not.exist(err);
171177
}
@@ -271,4 +277,4 @@ describe('219. aq3.js', function() {
271277
should.not.exist(err);
272278
}
273279
}); // 219.9
274-
});
280+
});

0 commit comments

Comments
 (0)