Skip to content

Commit

Permalink
Merge pull request #170 from ryanseys/disable-pubsub
Browse files Browse the repository at this point in the history
Ignore pub sub before test hook
  • Loading branch information
Burcu Dogan committed Sep 3, 2014
2 parents 751b266 + 6670f2a commit 12323f5
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 96 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,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"
}
190 changes: 97 additions & 93 deletions regression/pubsub.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {});
});
});
});

0 comments on commit 12323f5

Please sign in to comment.