Permalink
Browse files

Added tests for message.touch and message.release

  • Loading branch information...
1 parent 861f7c2 commit d1030dac0b3d61afc3ed358c4ae5dc2fe7ef6b92 @ahallock committed Jan 27, 2013
Showing with 65 additions and 0 deletions.
  1. +11 −0 README.md
  2. +54 −0 test/queue-test.js
View
@@ -21,6 +21,17 @@ q.get(function(err, message) {
message.del(function(err) {
});
+ // need more time?
+ // touch the message
+ message.touch(function(err) {
+
+ });
+
+ // can't process the message
+ // release the message
+ message.release(function(err) {
+
+ });
});
// Enqueue a message
View
@@ -81,6 +81,28 @@ describe('Queue', function() {
],
"timeout": 600
})
+ .get(projectPath + '/queues/myqueue/messages')
+ .reply(200, {
+ "messages": [
+ {
+ "id": "1",
+ "body": "first message body",
+ "timeout": 600
+ }
+ ],
+ "timeout": 600
+ })
+ .get(projectPath + '/queues/myqueue/messages')
+ .reply(200, {
+ "messages": [
+ {
+ "id": "1",
+ "body": "first message body",
+ "timeout": 600
+ }
+ ],
+ "timeout": 600
+ })
.delete(projectPath + '/queues/myqueue/messages/1')
.reply(200, {
"msg": "Deleted"
@@ -104,6 +126,14 @@ describe('Queue', function() {
.reply(200, {
"msg": "Touched"
})
+ .post(projectPath + '/queues/myqueue/messages/1/touch')
+ .reply(200, {
+ "msg": "Touched"
+ })
+ .post(projectPath + '/queues/myqueue/messages/1/release')
+ .reply(200, {
+ "msg": "Released"
+ })
.post(projectPath + '/queues/myqueue/messages/1/release')
.reply(200, {
"msg": "Released"
@@ -227,6 +257,30 @@ describe('Queue', function() {
});
});
});
+ describe('#msg.touch()', function() {
+ // kinky
+ it('should touch itself', function(done) {
+ project.queues('myqueue').get(function(err, msg) {
+ msg.touch(function(err, res) {
+ should.not.exist(err);
+ res.msg.should.equal('Touched');
+ done();
+ });
+ });
+ });
+ });
+ describe('#msg.release()', function() {
+ // kinky
+ it('should release itself', function(done) {
+ project.queues('myqueue').get(function(err, msg) {
+ msg.release(function(err, res) {
+ should.not.exist(err);
+ res.msg.should.equal('Released');
+ done();
+ });
+ });
+ });
+ });
describe('#peek()', function() {
it('should return next messages in the queue', function(done) {
project.queues('myqueue').peek(100, function(err, messages) {

0 comments on commit d1030da

Please sign in to comment.