[Groonga-commit] groonga/express-kotoumi [master] Test behaviours of Connection about socket error and reconnection to the backend

アーカイブの一覧に戻る

YUKI Hiroshi null+****@clear*****
Wed Jan 30 12:23:47 JST 2013


YUKI Hiroshi	2013-01-30 12:23:47 +0900 (Wed, 30 Jan 2013)

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

  Log:
    Test behaviours of Connection about socket error and reconnection to the backend

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

  Modified: test/backend-connection.test.js (+25 -1)
===================================================================
--- test/backend-connection.test.js    2013-01-30 12:22:49 +0900 (fcac4a8)
+++ test/backend-connection.test.js    2013-01-30 12:23:47 +0900 (764413f)
@@ -447,6 +447,7 @@ suite('Connection, to backend', function() {
   });
 
   test('disconnected suddenly', function(done) {
+    var errorHandler;
     var restartedBackend;
     Deferred
       .wait(0.01)
@@ -466,13 +467,36 @@ suite('Connection, to backend', function() {
       })
       .next(function(newBackend) {
         restartedBackend = newBackend;
+
+        errorHandler = nodemock
+          .mock('handle')
+            .takes({});
+        connection.on('error', function(error) {
+          errorHandler.handle(error);
+        });
+
         connection.emitMessage('test', { message: true });
       })
       .wait(0.1)
       .next(function() {
+        errorHandler.assertThrows();
+        assert.equal(backend.received.length,
+                     1,
+                     'no new message should be sent to the old backend');
+        assert.equal(restartedBackend.received.length,
+                     0,
+                     'message should be destroyed by socket error');
+
+        connection.emitMessage('test', { message: true });
+      })
+      .wait(0.01)
+      .next(function() {
+        assert.equal(backend.received.length,
+                     1,
+                     'no new message should be sent to the old backend');
         assert.equal(restartedBackend.received.length,
                      1,
-                     'message should be sent to the restarted backend');
+                     'message should be sent to the new backend');
         done();
       })
       .error(function(error) {
-------------- next part --------------
HTML����������������������������...
ダウンロード 



More information about the Groonga-commit mailing list
アーカイブの一覧に戻る