|
1 | 1 | var HttpClient = require('../../lib/http-client'), |
2 | 2 | HttpMeta = require('../../lib/http-meta'), |
3 | | - seq = require('seq'), |
| 3 | + should = require('should'), |
4 | 4 | util = require('util'), |
5 | 5 | assert = require('assert'), |
6 | 6 | test = require('../../lib/utils').test; |
7 | 7 |
|
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; |
17 | 9 |
|
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 | + }); |
43 | 30 | }); |
| 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 | + }) |
44 | 42 | }) |
45 | | -.seq(function() { |
46 | | - process.exit(0); |
47 | | -}); |
| 43 | + |
0 commit comments