[Groonga-commit] groonga/express-droonga at d773d68 [master] test: return response on receiving request instead of using wait()

Back to archive index

Kouhei Sutou null+****@clear*****
Sun Jul 21 17:27:19 JST 2013


Kouhei Sutou	2013-07-21 17:27:19 +0900 (Sun, 21 Jul 2013)

  New Revision: d773d6809b37aaafac4b76c34f0435f72747a4aa
  https://github.com/groonga/express-droonga/commit/d773d6809b37aaafac4b76c34f0435f72747a4aa

  Message:
    test: return response on receiving request instead of using wait()
    
    wait() makes test fragile.

  Modified files:
    test/express-adaptor.test.js

  Modified: test/express-adaptor.test.js (+11 -15)
===================================================================
--- test/express-adaptor.test.js    2013-07-21 17:04:02 +0900 (bb0bcc2)
+++ test/express-adaptor.test.js    2013-07-21 17:27:19 +0900 (9a13e94)
@@ -53,25 +53,21 @@ suite('Adaption for express application', function() {
         plugins:    [testRestPlugin, testSocketPlugin]
       });
 
-      var responseBody;
+      backend.reserveResponse(function(request) {
+        return utils.createReplyPacket(request,
+                                       {
+                                         statusCode: 200,
+                                         body:       'API response',
+                                       });
+      });
+
       utils.get('/path/to/api')
         .next(function(response) {
-          responseBody = response.body;
-        });
-
-      Deferred
-        .wait(0.01)
-        .next(function() {
           backend.assertReceived([{ type: 'api',
                                     body: 'api requested' }]);
-
-          return backend.sendResponse(backend.getMessages()[0],
-                                      'api.result',
-                                      'api OK?');
-        })
-        .wait(0.01)
-        .next(function() {
-          assert.equal(responseBody, 'api OK');
+          assert.deepEqual(response,
+                           { statusCode: 200,
+                             body:       JSON.stringify('api OK') });
           done();
         })
         .error(function(error) {
-------------- next part --------------
HTML����������������������������...
Download 



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