From 23ed686f58f3575441feecb75c1596a175d43e8b Mon Sep 17 00:00:00 2001 From: Stephen Sawchuk Date: Mon, 15 Dec 2014 13:10:56 -0500 Subject: [PATCH] fix pubsub tests. --- lib/pubsub/topic.js | 2 +- regression/pubsub.js | 25 +++++++++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/lib/pubsub/topic.js b/lib/pubsub/topic.js index 1e7d1d8997c..5dd8fc27e10 100644 --- a/lib/pubsub/topic.js +++ b/lib/pubsub/topic.js @@ -115,7 +115,7 @@ Topic.prototype.publish = function(message, callback) { * * @param {object} message - Raw message to publish. * @param {array=} message.label - List of labels for the message. - * @param {*} message.data - The contents of the message. + * @param {string} message.data - The base64-encoded contents of the message. * @param {function=} callback - The callback function. * * @example diff --git a/regression/pubsub.js b/regression/pubsub.js index c230fe97bb5..f92a16137cf 100644 --- a/regression/pubsub.js +++ b/regression/pubsub.js @@ -179,11 +179,28 @@ describe('pubsub', function() { subscription.ack(msg.id, done); }); topic.publish('hello', assert.ifError); + }); + + it('should receive the published message', function(done) { + var subscription = topic.subscription(subscriptions[0].name); + subscription.pull({ returnImmediately: true }, function(err, msg) { + assert.ifError(err); + assert.equal(msg.data, 'hello'); + subscription.ack(msg.id, done); + }); topic.publish('hello', assert.ifError); - topic.publish('hello', assert.ifError); - topic.publish('hello', assert.ifError); - topic.publish('hello', assert.ifError); - topic.publish('hello', assert.ifError); + }); + + it('should receive a raw published message', function(done) { + var subscription = topic.subscription(subscriptions[0].name); + subscription.pull({ returnImmediately: true }, function(err, msg) { + assert.ifError(err); + assert.equal(msg.data, 'hello'); + subscription.ack(msg.id, done); + }); + topic.publishRaw({ + data: new Buffer('hello').toString('base64') + }, assert.ifError); }); }); });