[Groonga-commit] groonga/express-kotoumi [master] test: Test multiple requests with same command name, to assert they won't be mixed

Back to archive index

YUKI Hiroshi null+****@clear*****
Wed Feb 13 21:00:01 JST 2013


YUKI Hiroshi	2013-02-13 21:00:01 +0900 (Wed, 13 Feb 2013)

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

  Log:
    test: Test multiple requests with same command name, to assert they won't be mixed

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

  Modified: test/backend-connection.test.js (+20 -24)
===================================================================
--- test/backend-connection.test.js    2013-02-13 20:43:59 +0900 (9350e16)
+++ test/backend-connection.test.js    2013-02-13 21:00:01 +0900 (5f18907)
@@ -171,17 +171,16 @@ suite('Connection', function() {
       test('success', function(done) {
         var callback = createMockedMessageCallback();
 
-        // these events should not be emitted!
-        connection.on('first response', callback);
-        connection.on('second response', callback);
+        // this event should not be emitted, because it is supressed by reply:* event
+        connection.on('result', callback);
 
         var messages = [
-          connection.emitMessage('first request', Math.random(), callback),
-          connection.emitMessage('second request', Math.random(), callback)
+          connection.emitMessage('event', Math.random(), callback),
+          connection.emitMessage('event', Math.random(), callback)
         ];
         var responses = [
-          utils.createReplyEnvelope(messages[0], 'first response', Math.random()),
-          utils.createReplyEnvelope(messages[1], 'second response', Math.random())
+          utils.createReplyEnvelope(messages[0], 'result', Math.random()),
+          utils.createReplyEnvelope(messages[1], 'result', Math.random())
         ];
         callback
           .takes(null, responses[0])
@@ -218,17 +217,16 @@ suite('Connection', function() {
       test('error', function(done) {
         var callback = createMockedMessageCallback();
 
-        // these events should not be emitted!
-        connection.on('first response', callback);
-        connection.on('second response', callback);
+        // this event should not be emitted, because it is supressed by reply:* event
+        connection.on('result', callback);
 
         var messages = [
-          connection.emitMessage('first request', Math.random(), callback),
-          connection.emitMessage('second request', Math.random(), callback)
+          connection.emitMessage('event', Math.random(), callback),
+          connection.emitMessage('event', Math.random(), callback)
         ];
         var responses = [
-          utils.createReplyEnvelope(messages[0], 'first response', Math.random()),
-          utils.createReplyEnvelope(messages[1], 'second response', Math.random())
+          utils.createReplyEnvelope(messages[0], 'result', Math.random()),
+          utils.createReplyEnvelope(messages[1], 'result', Math.random())
         ];
         // make them error responses
         responses[0].statusCode = 502;
@@ -268,20 +266,18 @@ suite('Connection', function() {
       test('duplicated', function(done) {
         var callback = createMockedMessageCallback();
 
-        // these events should not be emitted!
-        connection.on('first response', callback);
-        connection.on('second response', callback);
-        connection.on('duplicated, ignored', callback);
+        // this event should not be emitted, because it is supressed by reply:* event
+        connection.on('result', callback);
 
         var messages = [
-          connection.emitMessage('first request', Math.random(), callback),
-          connection.emitMessage('second request', Math.random(), callback)
+          connection.emitMessage('event', Math.random(), callback),
+          connection.emitMessage('event', Math.random(), callback)
         ];
         var responses = [
-          utils.createReplyEnvelope(messages[0], 'first response', Math.random()),
-          utils.createReplyEnvelope(messages[1], 'second response', Math.random()),
-          utils.createReplyEnvelope(messages[0], 'duplicated, ignored', 0),
-          utils.createReplyEnvelope(messages[1], 'duplicated, ignored', 0)
+          utils.createReplyEnvelope(messages[0], 'result', Math.random()),
+          utils.createReplyEnvelope(messages[1], 'result', Math.random()),
+          utils.createReplyEnvelope(messages[0], 'result', 'duplicated, ignored'),
+          utils.createReplyEnvelope(messages[1], 'result', 'duplicated, ignored')
         ];
         responses[1].statusCode = 503;
         callback
-------------- next part --------------
HTML����������������������������...
Download 



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