YUKI Hiroshi
null+****@clear*****
Fri Oct 17 16:53:45 JST 2014
YUKI Hiroshi 2014-10-17 16:53:45 +0900 (Fri, 17 Oct 2014) New Revision: aa2f552c6e0f54a97b326321d055db801a707de2 https://github.com/droonga/express-droonga/commit/aa2f552c6e0f54a97b326321d055db801a707de2 Message: Add tests for Connections Added files: test/droonga-protocol/connections.test.js Added: test/droonga-protocol/connections.test.js (+94 -0) 100644 =================================================================== --- /dev/null +++ test/droonga-protocol/connections.test.js 2014-10-17 16:53:45 +0900 (90c28e6) @@ -0,0 +1,94 @@ +var assert = require('chai').assert; + +var utils = require('../test-utils'); + +var Connections = require('../../lib/droonga-protocol/connections').Connections; + +suite('Connections', function() { + suite('initialization', function() { + var connections; + + teardown(function() { + if (connections) { + connections.closeAll(); + connections = undefined; + } + }); + + test('single', function() { + connections = new Connections({ + hostNames: [ + '127.0.0.1' + ] + }); + assert.equal(connections.count, 1); + }); + + test('multiple', function() { + connections = new Connections({ + hostNames: [ + '127.0.0.1', + '127.0.0.2' + ] + }); + assert.equal(connections.count, 2); + }); + + test('duplicated', function() { + connections = new Connections({ + hostNames: [ + '127.0.0.1', + '127.0.0.1' + ] + }); + assert.equal(connections.count, 1); + }); + }); + + suite('get', function() { + var connections; + + teardown(function() { + if (connections) { + connections.closeAll(); + connections = undefined; + } + }); + + test('single', function() { + connections = new Connections({ + hostNames: [ + '127.0.0.1' + ] + }); + var connection = connections.get(); + assert.isNotNull(connection); + assert.equal(connection.hostName, '127.0.0.1'); + }); + + test('multiple', function() { + connections = new Connections({ + hostNames: [ + '127.0.0.1', + '127.0.0.2', + '127.0.0.3' + ] + }); + var connection = connections.get(); + assert.isNotNull(connection); + assert.equal(connection.hostName, '127.0.0.1'); + + connection = connections.get(); + assert.isNotNull(connection); + assert.equal(connection.hostName, '127.0.0.2'); + + connection = connections.get(); + assert.isNotNull(connection); + assert.equal(connection.hostName, '127.0.0.3'); + + connection = connections.get(); + assert.isNotNull(connection); + assert.equal(connection.hostName, '127.0.0.1'); + }); + }); +}); -------------- next part -------------- HTML����������������������������...Descargar