Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/pubsub/topic.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 21 additions & 4 deletions regression/pubsub.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

This comment was marked as spam.

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