Skip to content

Commit 80c0f37

Browse files
committed
Adapt test to use should/mocha.
1 parent 7e0c541 commit 80c0f37

File tree

1 file changed

+34
-38
lines changed

1 file changed

+34
-38
lines changed
Lines changed: 34 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,43 @@
11
var HttpClient = require('../../lib/http-client'),
22
HttpMeta = require('../../lib/http-meta'),
3-
seq = require('seq'),
3+
should = require('should'),
44
util = require('util'),
55
assert = require('assert'),
66
test = require('../../lib/utils').test;
77

8-
var db = new HttpClient({ pool: {
9-
servers: [
10-
'localhost:10018',
11-
'localhost:10028',
12-
'localhost:10038',
13-
'localhost:10048'
14-
],
15-
options: {}
16-
}});
8+
var db;
179

18-
seq()
19-
.seq(function() {
20-
test('Creates an object');
21-
db.save('languages', 'erlang', {type: 'functional'}, function(err) {
22-
this.ok();
23-
}.bind(this));
24-
})
25-
.seq(function() {
26-
test('Get that object');
27-
db.get('languages', 'erlang', function(err, data) {
28-
assert(!err);
29-
assert.equal(data.type, 'functional');
30-
this.ok();
31-
}.bind(this));
32-
})
33-
.seq(function() {
34-
test('Get the streamed object');
35-
var self = this;
36-
db.get('languages', 'erlang', {stream: true}, function(err, response, meta) {
37-
assert(!err);
38-
response.on('data', function(data) {
39-
data = JSON.parse(String(data));
40-
assert.equal(data.type, 'functional');
41-
self.ok();
42-
}.bind(this));
10+
describe('http-client-pool', function () {
11+
before(function(done) {
12+
db = new HttpClient({ pool: {
13+
servers: [
14+
'localhost:8098',
15+
'localhost:8098'
16+
],
17+
options: {}
18+
}});
19+
done();
20+
});
21+
22+
it('Creates an object', function(done) {
23+
db.save('languages', 'erlang', {type: 'functional'}, function(err) {
24+
db.get('languages', 'erlang', function(err, data) {
25+
should.not.exist(err);
26+
data.type.should.equal('functional');
27+
done();
28+
});
29+
});
4330
});
31+
32+
it('Fetches the streamed object', function(done) {
33+
db.get('languages', 'erlang', {stream: true}, function(err, response, meta) {
34+
assert(!err);
35+
response.on('data', function(data) {
36+
data = JSON.parse(String(data));
37+
data.type.should.equal('functional');
38+
done();
39+
});
40+
});
41+
})
4442
})
45-
.seq(function() {
46-
process.exit(0);
47-
});
43+

0 commit comments

Comments
 (0)