[Groonga-commit] groonga/express-kotoumi [master] test: Test Socket.IO API's pub-sub command with multiple clients

アーカイブの一覧に戻る

YUKI Hiroshi null+****@clear*****
Wed Feb 13 16:06:09 JST 2013


YUKI Hiroshi	2013-02-13 16:06:09 +0900 (Wed, 13 Feb 2013)

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

  Log:
    test: Test Socket.IO API's pub-sub command with multiple clients

  Modified files:
    test/frontend-socket.io-adaptor.test.js
    test/test-utils.js

  Modified: test/frontend-socket.io-adaptor.test.js (+25 -9)
===================================================================
--- test/frontend-socket.io-adaptor.test.js    2013-02-13 15:55:09 +0900 (d250294)
+++ test/frontend-socket.io-adaptor.test.js    2013-02-13 16:06:09 +0900 (2f2b8d7)
@@ -35,7 +35,7 @@ suite('Socket.IO API', function() {
 
   teardown(function() {
     if (connection) {
-      utils.readyToDestroyMockedConnection(connection);
+      utils.readyToDestroyMockedConnection(connection, clientSockets.length);
       connection = undefined;
     }
     if (clientSockets.length) {
@@ -144,8 +144,8 @@ suite('Socket.IO API', function() {
       });
   });
 
-  test('one way: single client, front to back', function(done) {
-    connection = utils.createMockedBackendConnection(testPlugin);
+  test('one way, front to back', function(done) {
+    connection = utils.createMockedBackendConnection(testPlugin, 3);
 
     var application = express();
     utils.setupServer(application)
@@ -155,15 +155,22 @@ suite('Socket.IO API', function() {
           connection: connection,
           plugins: [testPlugin]
         });
-        return utils.createClientSocket();
+        return Deferred.parallel(
+          utils.createClientSocket(),
+          utils.createClientSocket(),
+          utils.createClientSocket()
+        );
       })
-      .next(function(newClientSocket) {
-        clientSockets.push(newClientSocket);
+      .next(function(newClientSockets) {
+        clientSockets = clientSockets.concat(newClientSockets);
         connection.assertThrows();
 
         var messages = [
           Math.random(),
           Math.random(),
+          Math.random(),
+          Math.random(),
+          Math.random(),
           Math.random()
         ];
         connection = connection
@@ -172,11 +179,20 @@ suite('Socket.IO API', function() {
           .mock('emitMessage')
             .takes('publish-subscribe', messages[1], null, {})
           .mock('emitMessage')
-            .takes('publish-subscribe', messages[2], null, {});
+            .takes('publish-subscribe', messages[2], null, {})
+          .mock('emitMessage')
+            .takes('publish-subscribe', messages[3], null, {})
+          .mock('emitMessage')
+            .takes('publish-subscribe', messages[4], null, {})
+          .mock('emitMessage')
+            .takes('publish-subscribe', messages[5], null, {});
 
         clientSockets[0].emit('publish-subscribe', messages[0]);
-        clientSockets[0].emit('publish-subscribe', messages[1]);
-        clientSockets[0].emit('publish-subscribe', messages[2]);
+        clientSockets[1].emit('publish-subscribe', messages[1]);
+        clientSockets[2].emit('publish-subscribe', messages[2]);
+        clientSockets[0].emit('publish-subscribe', messages[3]);
+        clientSockets[1].emit('publish-subscribe', messages[4]);
+        clientSockets[2].emit('publish-subscribe', messages[5]);
       })
       .wait(0.01)
       .next(function() {

  Modified: test/test-utils.js (+3 -1)
===================================================================
--- test/test-utils.js    2013-02-13 15:55:09 +0900 (dc00718)
+++ test/test-utils.js    2013-02-13 16:06:09 +0900 (ab65755)
@@ -190,10 +190,12 @@ function createStubbedBackendConnection() {
 }
 exports.createStubbedBackendConnection = createStubbedBackendConnection;
 
-function readyToDestroyMockedConnection(connection) {
+function readyToDestroyMockedConnection(connection, clientCount) {
   connection = connection
     .mock('removeListener')
       .takes('error', function() {});
+  if (clientCount)
+    connection = connection.times(clientCount);
   return connection;
 }
 exports.readyToDestroyMockedConnection = readyToDestroyMockedConnection;
-------------- next part --------------
HTML����������������������������...
ダウンロード 



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