[Groonga-commit] groonga/express-kotoumi [master] test: Test timeout feature for the callback listener of emitMessage correctly

Back to archive index

YUKI Hiroshi null+****@clear*****
Tue Jan 29 16:05:14 JST 2013


YUKI Hiroshi	2013-01-29 16:05:14 +0900 (Tue, 29 Jan 2013)

  New Revision: eecad4699347b169abbe849cdb3eac8eb2d00157
  https://github.com/groonga/express-kotoumi/commit/eecad4699347b169abbe849cdb3eac8eb2d00157

  Log:
    test: Test timeout feature for the callback listener of emitMessage correctly

  Modified files:
    test/backend-connection.test.js

  Modified: test/backend-connection.test.js (+13 -7)
===================================================================
--- test/backend-connection.test.js    2013-01-29 15:55:19 +0900 (99ea90e)
+++ test/backend-connection.test.js    2013-01-29 16:05:14 +0900 (84a98ee)
@@ -297,7 +297,7 @@ suite('Connection, basic features', function() {
         assert.deepEqual(backend.received[0][2], message);
         assert.equal(connection.listeners('inReplyTo:' + message.id).length,
                      1,
-                     'response listener should be there');
+                     'response listener should be still there');
 
         response = createReplyEnvelopeFor(message,
                                           'testResponse',
@@ -329,18 +329,24 @@ suite('Connection, basic features', function() {
         message = connection.emitMessage('testRequest',
                                          { command: 'foobar' },
                                          callback,
-                                         { timeout:  1,
-                                           delay:    10 });
+                                         { timeout: 20 });
         assert.envelopeEqual(message,
                              createExpectedEnvelope('testRequest',
                                                     { command: 'foobar' }));
       })
-      .wait(0.05)
+      .wait(0.01)
+      .next(function() {
+        assert.equal(backend.received.length, 1, 'message should be sent');
+        assert.deepEqual(backend.received[0][2], message);
+        assert.equal(connection.listeners('inReplyTo:' + message.id).length,
+                     1,
+                     'response listener should be still there');
+      })
+      .wait(0.02)
       .next(function() {
-        assert.equal(backend.received.length, 0, 'no message should be sent');
         assert.equal(connection.listeners('inReplyTo:' + message.id).length,
                      0,
-                     'response listener should be removed');
+                     'response listener should be removed by timeout');
         callback.assert();
         done();
       })
@@ -371,7 +377,7 @@ suite('Connection, basic features', function() {
         assert.deepEqual(backend.received[0][2], message);
         assert.equal(connection.listeners('inReplyTo:' + message.id).length,
                      1,
-                     'response listener should be there');
+                     'response listener should be still there');
 
         response = createReplyEnvelopeFor(message, 'testResponse', 'first call');
         callback.takes(null, response);
-------------- next part --------------
HTML����������������������������...
다운로드 



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