Skip to content

Commit

Permalink
fix coverage decrease
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenplusplus committed Mar 27, 2017
1 parent d0accde commit ed4f719
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
13 changes: 6 additions & 7 deletions packages/pubsub/src/subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,15 +437,14 @@ Subscription.prototype.ack = function(ackIds, options, callback) {
].join(''));
}

if (!callback) {
if (is.fn(options)) {
callback = options;
options = {};
} else {
callback = common.util.noop;
}
if (is.fn(options)) {
callback = options;
options = {};
}

options = options || {};
callback = callback || common.util.noop;

var protoOpts = {
service: 'Subscriber',
method: 'acknowledge'
Expand Down
12 changes: 11 additions & 1 deletion packages/pubsub/test/subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ describe('Subscription', function() {
var SUB_NAME = 'test-subscription';
var SUB_FULL_NAME = 'projects/' + PROJECT_ID + '/subscriptions/' + SUB_NAME;
var PUBSUB = {
projectId: PROJECT_ID
projectId: PROJECT_ID,
request: util.noop
};
var message = 'howdy';
var messageBuffer = new Buffer(message).toString('base64');
Expand Down Expand Up @@ -423,6 +424,15 @@ describe('Subscription', function() {
subscription.ack('abc', options, assert.ifError);
});

it('should not require a callback', function() {
assert.doesNotThrow(function() {
subscription.ack('abc');
subscription.ack('abc', {
timeout: 10
});
});
});

it('should unmark the ack ids as being in progress', function(done) {
subscription.request = function(protoOpts, reqOpts, callback) {
callback();
Expand Down

0 comments on commit ed4f719

Please sign in to comment.