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); }); }); });