Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

# all queue services implemented

  • Loading branch information...
commit 579dacb0cf2364f3f1094a320f0a81a47fd184d9 1 parent a36ce6e
Juan Pablo Garcia Dalolla authored
Showing with 71 additions and 4 deletions.
  1. +14 −3 lib/waz-queues/service.js
  2. +57 −1 test/waz-queues/service.test.js
17 lib/waz-queues/service.js
View
@@ -108,10 +108,10 @@ Service.prototype.getMessages = function(name, options, callback) {
});
};
-Service.prototype.deleteMessage = function(name, messageId, popreceipt, callback){
+Service.prototype.deleteMessage = function(name, messageId, popReceipt, callback){
var service = this;
- service.execute('delete', name + '/messages/' + messageId, {popreceipt: popreceipt}, {'x-ms-version': '2009-09-19'}, null, function(response) {
+ service.execute('delete', name + '/messages/' + messageId, {popreceipt: popReceipt}, {'x-ms-version': '2009-09-19'}, null, function(response) {
if (service.parseError(response, callback))
return;
@@ -128,4 +128,15 @@ Service.prototype.clearMessages = function(name, callback){
callback(null, response.headers);
});
-};
+};
+
+Service.prototype.updateMessage = function(name, messageId, popReceipt, visibilityTimeout, callback){
+ var service = this;
+
+ service.execute('put', name + '/messages/' + messageId, {popreceipt: popReceipt, visibilitytimeout: visibilityTimeout}, {'x-ms-version': '2009-09-19'}, null, function(response) {
+ if (service.parseError(response, callback))
+ return;
+
+ callback(null, response.headers);
+ });
+};
58 test/waz-queues/service.test.js
View
@@ -370,7 +370,20 @@ module.exports = {
mock.verify();
},
-
+
+ 'should return an error when trying to delete message': function(){
+ var service = new Service({});
+ var mock = sinon.mock(service);
+
+ mock.expects("execute").yields({statusCode: 404}).once();
+
+ service.deleteMessage('queue1', 'messageid', 'popreceipt-value',function(err, data){
+ assert.equal(err.Code, 404);
+ });
+
+ mock.verify();
+ },
+
'should delete all messages from a queue': function(){
var service = new Service({});
var mock = sinon.mock(service);
@@ -386,4 +399,47 @@ module.exports = {
mock.verify();
},
+
+ 'should return an error when trying to clear messages': function(){
+ var service = new Service({});
+ var mock = sinon.mock(service);
+
+ mock.expects("execute").yields({statusCode: 404}).once();
+
+ service.clearMessages('queue1', function(err, data){
+ assert.equal(err.Code, 404);
+ });
+
+ mock.verify();
+ },
+
+ 'should update a message': function(){
+ var service = new Service({});
+ var mock = sinon.mock(service);
+
+ mock.expects("execute").withArgs('put', 'queue1/messages/messageid', {popreceipt: 'popreceipt-value', visibilitytimeout: 'visibilitytimeout-value' }, { 'x-ms-version': '2009-09-19' }, null)
+ .yields({statusCode: 204, headers: { 'x-ms-version': '2009-09-19', 'x-ms-request-id': 'id'}})
+ .once();
+
+ service.updateMessage('queue1', 'messageid', 'popreceipt-value', 'visibilitytimeout-value', function(err, data){
+ assert.equal(err, null);
+ assert.equal(data['x-ms-request-id'], 'id');
+ });
+
+ mock.verify();
+ },
+
+ 'should return an error when trying to update a messages': function(){
+ var service = new Service({});
+ var mock = sinon.mock(service);
+
+ mock.expects("execute").yields({statusCode: 404}).once();
+
+ service.updateMessage('queue1', 'messageid', 'popreceipt-value', 'visibilitytimeout-value', function(err, data){
+ assert.equal(err.Code, 404);
+ });
+
+ mock.verify();
+ },
+
}
Please sign in to comment.
Something went wrong with that request. Please try again.