Skip to content

Commit

Permalink
Merge pull request #150 from stephenplusplus/test-pubsub
Browse files Browse the repository at this point in the history
tests: pubsub: fix racy tests.
  • Loading branch information
Burcu Dogan committed Aug 29, 2014
2 parents 7e7c41f + 9e69d98 commit 797c6f6
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions test/pubsub/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,18 @@ describe('Subscription', function() {
projectId: 'test-project'
});
conn.makeReq = function(method, path, qs, body, callback) {
switch (path) {
case 'subscriptions//subscriptions/test-project/sub1':
callback(null, {});
return;
case 'subscriptions/pull':
callback(null, { ackId: 123 });
return;
if (path === 'subscriptions//subscriptions/test-project/sub1') {
callback(null, {});
return;
}
if (path === 'subscriptions/pull') {
callback(null, { ackId: 123 });
return;
}
};
var sub = conn.subscribe('sub1', { autoAck: false });
sub.on('message', function() {
sub.once('message', function() {
sub.close();
done();
});
});
Expand All @@ -69,22 +70,24 @@ describe('Subscription', function() {
projectId: 'test-project'
});
conn.makeReq = function(method, path, qs, body, callback) {
switch (path) {
case 'subscriptions//subscriptions/test-project/sub1':
callback(null, {});
return;
case 'subscriptions/pull':
setImmediate(function() {
callback(null, { ackId: 123 });
});
return;
case 'subscriptions/acknowledge':
callback(null, true);
return;
if (path === 'subscriptions//subscriptions/test-project/sub1') {
callback(null, {});
return;
}
if (path === 'subscriptions/pull') {
setImmediate(function() {
callback(null, { ackId: 123 });
});
return;
}
if (path === 'subscriptions/acknowledge') {
callback(null, true);
return;
}
};
var sub = conn.subscribe('sub1', { autoAck: true });
sub.on('message', function() {
sub.once('message', function() {
sub.close();
done();
});
});
Expand Down

0 comments on commit 797c6f6

Please sign in to comment.