Skip to content

Commit 12323f5

Browse files
author
Burcu Dogan
committed
Merge pull request #170 from ryanseys/disable-pubsub
Ignore pub sub before test hook
2 parents 751b266 + 6670f2a commit 12323f5

File tree

2 files changed

+100
-96
lines changed

2 files changed

+100
-96
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@
6565
"docs": "jsdoc -c .jsdoc.json && cp docs/module-gcloud.html docs/index.html",
6666
"lint": "jshint lib/ regression/ test/",
6767
"test": "mocha --recursive --reporter spec",
68-
"regression-test": "mocha regression/ --reporter spec --timeout 15000",
69-
"cover": "istanbul cover -x 'regression/* lib/pubsub/*' _mocha -- --timeout 15000 test/* regression/*",
70-
"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"
68+
"regression-test": "mocha regression/datastore.js regression/storage.js --reporter spec --timeout 15000",
69+
"cover": "istanbul cover -x 'regression/* lib/pubsub/*' _mocha -- --timeout 15000 test/* regression/datastore.js regression/storage.js",
70+
"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"
7171
},
7272
"license": "Apache 2"
7373
}

regression/pubsub.js

Lines changed: 97 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -38,128 +38,132 @@ var subscriptions = [
3838

3939
var conn = new gcloud.pubsub.Connection(env);
4040

41-
before(function(done) {
42-
// TODO: Handle pagination.
43-
var createFn = function(name, callback) {
44-
conn.createTopic(name, callback);
45-
};
46-
conn.listTopics(function(err, topics) {
47-
assert.ifError(err);
48-
var fns = topics.map(function(t) {
49-
return function(cb) {
50-
t.del(cb);
51-
};
52-
});
53-
async.parallel(fns, function(err) {
41+
describe('pubsub', function() {
42+
43+
before(function(done) {
44+
// TODO: Handle pagination.
45+
var createFn = function(name, callback) {
46+
conn.createTopic(name, callback);
47+
};
48+
conn.listTopics(function(err, topics) {
5449
assert.ifError(err);
55-
async.map(topicNames, createFn, done);
50+
var fns = topics.map(function(t) {
51+
return function(cb) {
52+
t.del(cb);
53+
};
54+
});
55+
async.parallel(fns, function(err) {
56+
assert.ifError(err);
57+
async.map(topicNames, createFn, done);
58+
});
5659
});
5760
});
58-
});
5961

60-
describe.skip('Topic', function() {
61-
it('should be listed', function(done) {
62-
conn.listTopics(function(err, topics) {
63-
assert(topics.length, 3);
64-
done(err);
62+
describe('Topic', function() {
63+
it('should be listed', function(done) {
64+
conn.listTopics(function(err, topics) {
65+
assert(topics.length, 3);
66+
done(err);
67+
});
6568
});
66-
});
6769

68-
it('should return a nextQuery if there are more results', function(done) {
69-
conn.listTopics({ maxResults: 2 }, function(err, topics, next) {
70-
assert(topics.length, 2);
71-
assert(next.maxResults, 2);
72-
assert(!!next.pageToken, true);
73-
done(err);
70+
it('should return a nextQuery if there are more results', function(done) {
71+
conn.listTopics({ maxResults: 2 }, function(err, topics, next) {
72+
assert(topics.length, 2);
73+
assert(next.maxResults, 2);
74+
assert(!!next.pageToken, true);
75+
done(err);
76+
});
7477
});
75-
});
7678

77-
it('should be created', function(done) {
78-
conn.createTopic('topic-new', done);
79-
});
79+
it('should be created', function(done) {
80+
conn.createTopic('topic-new', done);
81+
});
8082

81-
it('should be gettable', function(done) {
82-
conn.getTopic('topic1', done);
83-
});
83+
it('should be gettable', function(done) {
84+
conn.getTopic('topic1', done);
85+
});
8486

85-
it('should publish a message', function(done) {
86-
conn.getTopic('topic1', function(err, topic) {
87-
topic.publish('message from me', done);
87+
it('should publish a message', function(done) {
88+
conn.getTopic('topic1', function(err, topic) {
89+
topic.publish('message from me', done);
90+
});
8891
});
89-
});
9092

91-
it('should be deleted', function(done) {
92-
conn.getTopic('topic3', function(err, topic) {
93-
topic.del(done);
93+
it('should be deleted', function(done) {
94+
conn.getTopic('topic3', function(err, topic) {
95+
topic.del(done);
96+
});
9497
});
9598
});
96-
});
9799

98-
describe.skip('Subscription', function() {
99-
before(function(done) {
100-
var createFn = function(item, callback) {
101-
conn.createSubscription({
102-
name: item.name,
103-
topic: 'topic1',
104-
ackDeadlineSeconds: item.ackDeadlineSeconds
105-
}, callback);
106-
};
107-
conn.listSubscriptions(function(err, subs) {
108-
assert.ifError(err);
109-
var fns = subs.map(function(sub) {
110-
return function(cb) {
111-
sub.del(cb);
112-
};
113-
});
114-
async.series(fns, function(err) {
100+
describe('Subscription', function() {
101+
before(function(done) {
102+
var createFn = function(item, callback) {
103+
conn.createSubscription({
104+
name: item.name,
105+
topic: 'topic1',
106+
ackDeadlineSeconds: item.ackDeadlineSeconds
107+
}, callback);
108+
};
109+
conn.listSubscriptions(function(err, subs) {
115110
assert.ifError(err);
116-
async.map(subscriptions, createFn, done);
111+
var fns = subs.map(function(sub) {
112+
return function(cb) {
113+
sub.del(cb);
114+
};
115+
});
116+
async.series(fns, function(err) {
117+
assert.ifError(err);
118+
async.map(subscriptions, createFn, done);
119+
});
117120
});
118121
});
119-
});
120122

121-
it('should be listed', function(done) {
122-
conn.listSubscriptions(function(err, subs) {
123-
assert.strictEqual(subs.length, 2);
124-
done(err);
123+
it('should be listed', function(done) {
124+
conn.listSubscriptions(function(err, subs) {
125+
assert.strictEqual(subs.length, 2);
126+
done(err);
127+
});
125128
});
126-
});
127129

128-
it('should be gettable', function(done) {
129-
conn.getSubscription('sub1', function(err, sub) {
130-
assert.ifError(err);
131-
assert.strictEqual(sub.name, '/subscriptions/' + env.projectId + '/sub1');
132-
done();
130+
it('should be gettable', function(done) {
131+
conn.getSubscription('sub1', function(err, sub) {
132+
assert.ifError(err);
133+
assert.strictEqual(sub.name, '/subscriptions/' + env.projectId +
134+
'/sub1');
135+
done();
136+
});
133137
});
134-
});
135138

136-
it('should error while getting a non-existent subscription', function(done){
137-
conn.getSubscription('sub-nothing-is-here', function(err) {
138-
assert.strictEqual(err.code, 404);
139-
done();
139+
it('should error while getting a non-existent subscription', function(done){
140+
conn.getSubscription('sub-nothing-is-here', function(err) {
141+
assert.strictEqual(err.code, 404);
142+
done();
143+
});
140144
});
141-
});
142145

143-
it('should be created', function(done) {
144-
conn.createSubscription({
145-
topic: 'topic1',
146-
name: 'new-sub'
147-
}, done);
148-
});
146+
it('should be created', function(done) {
147+
conn.createSubscription({
148+
topic: 'topic1',
149+
name: 'new-sub'
150+
}, done);
151+
});
149152

150-
it('should be able to pull and ack', function(done) {
151-
conn.getTopic('topic1', function(err, topic) {
152-
assert.ifError(err);
153-
topic.publish('hello', function(err) {
153+
it('should be able to pull and ack', function(done) {
154+
conn.getTopic('topic1', function(err, topic) {
154155
assert.ifError(err);
156+
topic.publish('hello', function(err) {
157+
assert.ifError(err);
158+
});
155159
});
156-
});
157-
conn.getSubscription('sub1', function(err, sub) {
158-
assert.ifError(err);
159-
sub.on('message', function(msg) {
160-
sub.ack(msg.ackId, done);
160+
conn.getSubscription('sub1', function(err, sub) {
161+
assert.ifError(err);
162+
sub.on('message', function(msg) {
163+
sub.ack(msg.ackId, done);
164+
});
165+
sub.pull({}, function() {});
161166
});
162-
sub.pull({}, function() {});
163167
});
164168
});
165169
});

0 commit comments

Comments
 (0)