YUKI Hiroshi
null+****@clear*****
Fri Oct 17 18:03:31 JST 2014
YUKI Hiroshi 2014-10-17 18:03:31 +0900 (Fri, 17 Oct 2014) New Revision: a1080fd71abf8970dcad12bad4f66a5805fc09ce https://github.com/droonga/express-droonga/commit/a1080fd71abf8970dcad12bad4f66a5805fc09ce Message: Add a test for handling of HTTP requests with multiple connections Modified files: test/adapter/http.test.js Modified: test/adapter/http.test.js (+64 -0) =================================================================== --- test/adapter/http.test.js 2014-10-17 18:03:09 +0900 (23bf4f5) +++ test/adapter/http.test.js 2014-10-17 18:03:31 +0900 (2bb62c1) @@ -240,5 +240,69 @@ suite('HTTP Adapter', function() { .catch(done); }); }); + + suite('multiple backends', function() { + var testPlugin = { + adapter: new command.HTTPRequestResponse({ + path: '/endpoint', + onRequest: function(request, connection) { + connection.emit('adapter', 'requested ' + request.query.id); + }, + onResponse: function(data, response) { + response.status(200).jsonp('OK'); + } + }) + }; + + var server; + + teardown(function() { + if (server) { + server.close(); + server = undefined; + } + }); + + test('search', function(done) { + var receiverCallback = {}; + var connections = utils.createStubbedBackendConnections(3); + var application = express(); + httpAdapter.register(application, { + prefix: '', + connections: connections, + plugins: [ + testPlugin + ] + }); + utils.setupServer(application) + .then(function(newServer) { + server = newServer; + }) + .then(utils.getCb('/endpoint?id=1')) + .then(utils.getCb('/endpoint?id=2')) + .then(utils.getCb('/endpoint?id=3')) + .then(utils.getCb('/endpoint?id=4')) + .then(function() { + assert.deepEqual( + connections.connections.map(function(connection) { + return connection.emitMessageCalledArguments.map(function(args) { + return { + type: args.type, + message: args.message + }; + }); + }), + [ + [{ type: 'adapter', message: 'requested 1' }, + { type: 'adapter', message: 'requested 4' }], + [{ type: 'adapter', message: 'requested 2' }], + [{ type: 'adapter', message: 'requested 3' }] + ] + ); + done(); + }) + .catch(done); + }); + }); }); -------------- next part -------------- HTML����������������������������...Download