Skip to content

Commit

Permalink
Merge pull request #404 from ryanseys/rs--delete-subs
Browse files Browse the repository at this point in the history
Delete all subscriptions in pubsub reg tests
  • Loading branch information
ryanseys committed Feb 19, 2015
2 parents b8dff43 + 6dd9d59 commit 89a8132
Showing 1 changed file with 41 additions and 13 deletions.
54 changes: 41 additions & 13 deletions regression/pubsub.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,36 @@ describe('pubsub', function() {
});
}

function deleteAllSubscriptions(callback) {
pubsub.getSubscriptions(function(err, subs) {
if(err) {
callback(err);
return;
}
async.parallel(subs.map(function(sub) {
return sub.delete.bind(sub);
}), callback);
});
}

before(function(done) {
deleteAllTopics(function(err) {
deleteAllSubscriptions(function(err) {
assert.ifError(err);
// Create new topics.
async.map(topicNames, pubsub.createTopic.bind(pubsub), done);

deleteAllTopics(function(err) {
assert.ifError(err);
// Create new topics.
async.map(topicNames, pubsub.createTopic.bind(pubsub), done);
});
});
});

after(deleteAllTopics);
after(function(done) {
deleteAllSubscriptions(function(err) {
assert.ifError(err);
deleteAllTopics(done);
});
});

describe('Topic', function() {
it('should be listed', function(done) {
Expand Down Expand Up @@ -118,22 +139,29 @@ describe('pubsub', function() {
var topic;

before(function(done) {
deleteAllTopics(function(err) {
deleteAllSubscriptions(function(err) {
assert.ifError(err);
// Create a new test topic.
pubsub.createTopic(TOPIC_NAME, function(err, newTopic) {

deleteAllTopics(function(err) {
assert.ifError(err);
topic = newTopic;
// Create subscriptions.
async.parallel(subscriptions.map(function(sub) {
return topic.subscribe.bind(topic, sub.name, sub.options);
}), done);
// Create a new test topic.
pubsub.createTopic(TOPIC_NAME, function(err, newTopic) {
assert.ifError(err);
topic = newTopic;
// Create subscriptions.
async.parallel(subscriptions.map(function(sub) {
return topic.subscribe.bind(topic, sub.name, sub.options);
}), done);
});
});
});
});

after(function(done) {
topic.delete(done);
deleteAllSubscriptions(function(err) {
assert.ifError(err);
deleteAllTopics(done);
});
});

it('should list all subscriptions registered to the topic', function(done) {
Expand Down

0 comments on commit 89a8132

Please sign in to comment.