From 6670f2ab9bdf13a77fe50135f992c54827828bb4 Mon Sep 17 00:00:00 2001 From: Ryan Seys Date: Wed, 3 Sep 2014 15:08:45 -0400 Subject: [PATCH] Ignore pub sub before test hook --- package.json | 6 +- regression/pubsub.js | 190 ++++++++++++++++++++++--------------------- 2 files changed, 100 insertions(+), 96 deletions(-) diff --git a/package.json b/package.json index c60fd3e9179..8263cb3be0d 100644 --- a/package.json +++ b/package.json @@ -59,9 +59,9 @@ "docs": "jsdoc -c .jsdoc.json && cp docs/module-gcloud.html docs/index.html", "lint": "jshint lib/ regression/ test/", "test": "mocha --recursive --reporter spec", - "regression-test": "mocha regression/ --reporter spec --timeout 15000", - "cover": "istanbul cover -x 'regression/* lib/pubsub/*' _mocha -- --timeout 15000 test/* regression/*", - "coveralls": "istanbul cover -x 'regression/* lib/pubsub/*' _mocha --report lcovonly -- --timeout 15000 test/* regression/* -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage" + "regression-test": "mocha regression/datastore.js regression/storage.js --reporter spec --timeout 15000", + "cover": "istanbul cover -x 'regression/* lib/pubsub/*' _mocha -- --timeout 15000 test/* regression/datastore.js regression/storage.js", + "coveralls": "istanbul cover -x 'regression/* lib/pubsub/*' _mocha --report lcovonly -- --timeout 15000 test/* regression/datastore.js regression/storage.js -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage" }, "license": "Apache 2" } diff --git a/regression/pubsub.js b/regression/pubsub.js index 2bb96d65d22..d0dea40566d 100644 --- a/regression/pubsub.js +++ b/regression/pubsub.js @@ -38,128 +38,132 @@ var subscriptions = [ var conn = new gcloud.pubsub.Connection(env); -before(function(done) { - // TODO: Handle pagination. - var createFn = function(name, callback) { - conn.createTopic(name, callback); - }; - conn.listTopics(function(err, topics) { - assert.ifError(err); - var fns = topics.map(function(t) { - return function(cb) { - t.del(cb); - }; - }); - async.parallel(fns, function(err) { +describe('pubsub', function() { + + before(function(done) { + // TODO: Handle pagination. + var createFn = function(name, callback) { + conn.createTopic(name, callback); + }; + conn.listTopics(function(err, topics) { assert.ifError(err); - async.map(topicNames, createFn, done); + var fns = topics.map(function(t) { + return function(cb) { + t.del(cb); + }; + }); + async.parallel(fns, function(err) { + assert.ifError(err); + async.map(topicNames, createFn, done); + }); }); }); -}); -describe.skip('Topic', function() { - it('should be listed', function(done) { - conn.listTopics(function(err, topics) { - assert(topics.length, 3); - done(err); + describe('Topic', function() { + it('should be listed', function(done) { + conn.listTopics(function(err, topics) { + assert(topics.length, 3); + done(err); + }); }); - }); - it('should return a nextQuery if there are more results', function(done) { - conn.listTopics({ maxResults: 2 }, function(err, topics, next) { - assert(topics.length, 2); - assert(next.maxResults, 2); - assert(!!next.pageToken, true); - done(err); + it('should return a nextQuery if there are more results', function(done) { + conn.listTopics({ maxResults: 2 }, function(err, topics, next) { + assert(topics.length, 2); + assert(next.maxResults, 2); + assert(!!next.pageToken, true); + done(err); + }); }); - }); - it('should be created', function(done) { - conn.createTopic('topic-new', done); - }); + it('should be created', function(done) { + conn.createTopic('topic-new', done); + }); - it('should be gettable', function(done) { - conn.getTopic('topic1', done); - }); + it('should be gettable', function(done) { + conn.getTopic('topic1', done); + }); - it('should publish a message', function(done) { - conn.getTopic('topic1', function(err, topic) { - topic.publish('message from me', done); + it('should publish a message', function(done) { + conn.getTopic('topic1', function(err, topic) { + topic.publish('message from me', done); + }); }); - }); - it('should be deleted', function(done) { - conn.getTopic('topic3', function(err, topic) { - topic.del(done); + it('should be deleted', function(done) { + conn.getTopic('topic3', function(err, topic) { + topic.del(done); + }); }); }); -}); -describe.skip('Subscription', function() { - before(function(done) { - var createFn = function(item, callback) { - conn.createSubscription({ - name: item.name, - topic: 'topic1', - ackDeadlineSeconds: item.ackDeadlineSeconds - }, callback); - }; - conn.listSubscriptions(function(err, subs) { - assert.ifError(err); - var fns = subs.map(function(sub) { - return function(cb) { - sub.del(cb); - }; - }); - async.series(fns, function(err) { + describe('Subscription', function() { + before(function(done) { + var createFn = function(item, callback) { + conn.createSubscription({ + name: item.name, + topic: 'topic1', + ackDeadlineSeconds: item.ackDeadlineSeconds + }, callback); + }; + conn.listSubscriptions(function(err, subs) { assert.ifError(err); - async.map(subscriptions, createFn, done); + var fns = subs.map(function(sub) { + return function(cb) { + sub.del(cb); + }; + }); + async.series(fns, function(err) { + assert.ifError(err); + async.map(subscriptions, createFn, done); + }); }); }); - }); - it('should be listed', function(done) { - conn.listSubscriptions(function(err, subs) { - assert.strictEqual(subs.length, 2); - done(err); + it('should be listed', function(done) { + conn.listSubscriptions(function(err, subs) { + assert.strictEqual(subs.length, 2); + done(err); + }); }); - }); - it('should be gettable', function(done) { - conn.getSubscription('sub1', function(err, sub) { - assert.ifError(err); - assert.strictEqual(sub.name, '/subscriptions/' + env.projectId + '/sub1'); - done(); + it('should be gettable', function(done) { + conn.getSubscription('sub1', function(err, sub) { + assert.ifError(err); + assert.strictEqual(sub.name, '/subscriptions/' + env.projectId + + '/sub1'); + done(); + }); }); - }); - it('should error while getting a non-existent subscription', function(done){ - conn.getSubscription('sub-nothing-is-here', function(err) { - assert.strictEqual(err.code, 404); - done(); + it('should error while getting a non-existent subscription', function(done){ + conn.getSubscription('sub-nothing-is-here', function(err) { + assert.strictEqual(err.code, 404); + done(); + }); }); - }); - it('should be created', function(done) { - conn.createSubscription({ - topic: 'topic1', - name: 'new-sub' - }, done); - }); + it('should be created', function(done) { + conn.createSubscription({ + topic: 'topic1', + name: 'new-sub' + }, done); + }); - it('should be able to pull and ack', function(done) { - conn.getTopic('topic1', function(err, topic) { - assert.ifError(err); - topic.publish('hello', function(err) { + it('should be able to pull and ack', function(done) { + conn.getTopic('topic1', function(err, topic) { assert.ifError(err); + topic.publish('hello', function(err) { + assert.ifError(err); + }); }); - }); - conn.getSubscription('sub1', function(err, sub) { - assert.ifError(err); - sub.on('message', function(msg) { - sub.ack(msg.ackId, done); + conn.getSubscription('sub1', function(err, sub) { + assert.ifError(err); + sub.on('message', function(msg) { + sub.ack(msg.ackId, done); + }); + sub.pull({}, function() {}); }); - sub.pull({}, function() {}); }); }); });