[Groonga-commit] droonga/express-droonga at 6737a2e [master] Shrink scope of tests for HTTP adapters

Back to archive index

YUKI Hiroshi null+****@clear*****
Fri Oct 17 19:39:23 JST 2014


YUKI Hiroshi	2014-10-17 19:39:23 +0900 (Fri, 17 Oct 2014)

  New Revision: 6737a2ecb81f66ac9d680d272e42e8293df63f24
  https://github.com/droonga/express-droonga/commit/6737a2ecb81f66ac9d680d272e42e8293df63f24

  Message:
    Shrink scope of tests for HTTP adapters

  Modified files:
    test/adapter/http.test.js

  Modified: test/adapter/http.test.js (+33 -38)
===================================================================
--- test/adapter/http.test.js    2014-10-17 19:35:47 +0900 (9d409a1)
+++ test/adapter/http.test.js    2014-10-17 19:39:23 +0900 (1ee8ef1)
@@ -62,14 +62,12 @@ suite('HTTP Adapter', function() {
     var connectionPool;
     var application;
     var server;
-    var backend;
 
     setup(function(done) {
-      utils.setupApplication()
+      connectionPool = utils.createStubbedBackendConnectionPool();
+      utils.setupApplication({ connectionPool: connectionPool })
         .then(function(result) {
-          backend = result.backend;
           server = result.server;
-          connectionPool = result.connectionPool;
           application = result.application;
           done();
         })
@@ -77,8 +75,7 @@ suite('HTTP Adapter', function() {
     });
 
     teardown(function() {
-      utils.teardownApplication({ backend:    backend,
-                                  server:     server,
+      utils.teardownApplication({ server:     server,
                                   connectionPool: connectionPool });
     });
 
@@ -87,29 +84,26 @@ suite('HTTP Adapter', function() {
         prefix:     '',
         connectionPool: connectionPool,
         plugins:    [
-          api.API_REST,
-          api.API_SOCKET_IO,
-          api.API_GROONGA,
-          api.API_DROONGA,
           testPlugin
         ]
       });
 
-      backend.reserveResponse(function(request) {
-        return utils.createReplyPacket(request,
-                                       {
-                                         statusCode: 200,
-                                         body:       'Adapter response',
-                                       });
-      });
-
+      var responses = [];
       utils.get('/path/to/adapter')
-        .then(function(response) {
-          backend.assertReceived([{ type: 'adapter',
-                                    body: 'adapter requested' }]);
-          assert.deepEqual(response,
-                          { statusCode: 200,
-                            body:       JSON.stringify('adapter OK') });
+        .then(function(response) { responses.push(response); })
+        .then(function() {
+          assert.deepEqual(
+            connectionPool.emittedMessages,
+            [
+              [{ type: 'adapter', message: 'adapter requested' }]
+            ]
+          );
+          assert.deepEqual(
+            responses,
+            [
+              { statusCode: 200, body: JSON.stringify('adapter OK') }
+            ]
+          );
           done();
         })
         .catch(done);
@@ -128,21 +122,22 @@ suite('HTTP Adapter', function() {
         ]
       });
 
-      backend.reserveResponse(function(request) {
-        return utils.createReplyPacket(request,
-                                       {
-                                         statusCode: 200,
-                                         body:       'Adapter response',
-                                       });
-      });
-
+      var responses = [];
       utils.get('/path/to/droonga/path/to/adapter')
-        .then(function(response) {
-          backend.assertReceived([{ type: 'adapter',
-                                    body: 'adapter requested' }]);
-          assert.deepEqual(response,
-                          { statusCode: 200,
-                            body:       JSON.stringify('adapter OK') });
+        .then(function(response) { responses.push(response); })
+        .then(function() {
+          assert.deepEqual(
+            connectionPool.emittedMessages,
+            [
+              [{ type: 'adapter', message: 'adapter requested' }]
+            ]
+          );
+          assert.deepEqual(
+            responses,
+            [
+              { statusCode: 200, body: JSON.stringify('adapter OK') }
+            ]
+          );
           done();
         })
         .catch(done);
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index