YUKI Hiroshi
null+****@clear*****
Fri Oct 17 17:00:26 JST 2014
YUKI Hiroshi 2014-10-17 17:00:26 +0900 (Fri, 17 Oct 2014) New Revision: 7b865b5cb6aa23d5fda141deded0506dd497ee2e https://github.com/droonga/express-droonga/commit/7b865b5cb6aa23d5fda141deded0506dd497ee2e Message: Add new utility method to create stubbed backend connections Modified files: test/test-utils.js Modified: test/test-utils.js (+27 -2) =================================================================== --- test/test-utils.js 2014-10-17 16:53:45 +0900 (e17acbc) +++ test/test-utils.js 2014-10-17 17:00:26 +0900 (0c87a78) @@ -193,8 +193,13 @@ function createClients(count) { exports.createClients = createClients; registerCallbackGenerator('createClients'); -function createStubbedBackendConnection() { +function createStubbedBackendConnection(hostName) { + hostName = hostName || '127.0.0.1'; return { + hostName: hostName, + port: testReceivePort, + tag: testTag, + emitMessage: function(type, message, callback, options) { this.emitMessageCalledArguments.push({ type: type, @@ -205,7 +210,7 @@ function createStubbedBackendConnection() { }, emitMessageCalledArguments: [], getRouteToSelf: function() { - return '127.0.0.1:' + testReceivePort + '/' + testTag; + return hostName + ':' + testReceivePort + '/' + testTag; }, emit: function() {}, @@ -217,6 +222,26 @@ function createStubbedBackendConnection() { } exports.createStubbedBackendConnection = createStubbedBackendConnection; +function createStubbedBackendConnections(count) { + count = count || 1; + var connections = []; + for (var i = 0; i < count; i++) { + connections.push(createStubbedBackendConnection('127.0.0.' + (i + 1))); + } + return { + count: count, + get: function() { + var connection = connections[index]; + index++; + if (index == count) + index = 0; + return connection; + }, + closeAll: function() {} + }; +} +exports.createStubbedBackendConnections = createStubbedBackendConnections; + function setupApplication() { var application = express(); var server; -------------- next part -------------- HTML����������������������������... 다운로드