Skip to content

Commit

Permalink
Merge pull request #332 from stephenplusplus/spp--pubsub-reg-test-fixes
Browse files Browse the repository at this point in the history
fix pubsub tests.
  • Loading branch information
stephenplusplus committed Dec 16, 2014
2 parents 81d1c76 + 23ed686 commit cde8c45
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
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) {
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);
});
});
});

0 comments on commit cde8c45

Please sign in to comment.