[Groonga-commit] groonga/express-kotoumi [master] test: Send packet with delay

Back to archive index

YUKI Hiroshi null+****@clear*****
Mon Jan 28 13:27:23 JST 2013


YUKI Hiroshi	2013-01-28 13:27:23 +0900 (Mon, 28 Jan 2013)

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

  Log:
    test: Send packet with delay

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

  Modified: test/backend-receiver.test.js (+13 -3)
===================================================================
--- test/backend-receiver.test.js    2013-01-28 13:22:56 +0900 (4b6ce51)
+++ test/backend-receiver.test.js    2013-01-28 13:27:23 +0900 (0b7b503)
@@ -22,14 +22,24 @@ function connectTo(port) {
 }
 
 function sendPacketTo(packet, port) {
+  var clientSocket;
   return connectTo(port)
-    .next(function(clientSocket) {
+    .next(function(newSocket) {
+      clientSocket = newSocket;
       var packedPacket = msgpack.pack(packet);
       clientSocket.write(new Buffer(packedPacket));
-      return clientSocket;
     })
-    .next(function(clientSocket) {
+    .wait(0.01)
+    .next(function() {
       clientSocket.destroy();
+      clientSocket = undefined;
+    })
+    .error(function(error) {
+      if (clientSocket) {
+        clientSocket.destroy();
+        clientSocket = undefined;
+      }
+      throw error;
     });
 }
 
-------------- next part --------------
HTML����������������������������...
Download 



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