[Groonga-commit] groonga/express-droonga at efb3689 [master] test: add utility to create reply packate from request and reponse envelope

Back to archive index

Kouhei Sutou null+****@clear*****
Sun Jul 21 16:59:47 JST 2013


Kouhei Sutou	2013-07-21 16:59:47 +0900 (Sun, 21 Jul 2013)

  New Revision: efb368954cf18e7cc73116e759ee09cdb0df4e89
  https://github.com/groonga/express-droonga/commit/efb368954cf18e7cc73116e759ee09cdb0df4e89

  Message:
    test: add utility to create reply packate from request and reponse envelope

  Modified files:
    test/frontend-rest-adaptor.test.js
    test/test-utils.js

  Modified: test/frontend-rest-adaptor.test.js (+5 -12)
===================================================================
--- test/frontend-rest-adaptor.test.js    2013-07-21 16:37:32 +0900 (330bd87)
+++ test/frontend-rest-adaptor.test.js    2013-07-21 16:59:47 +0900 (253ff75)
@@ -108,18 +108,11 @@ suite('REST API', function() {
       });
 
       backend.reserveResponse(function(request) {
-        var tag = request[0];
-        var timestamp = 0;
-        var envelope = request[2];
-        return [
-          tag,
-          timestamp,
-          {
-            inReplyTo:  envelope.id,
-            statusCode: 200,
-            body:       'API response'
-          }
-        ];
+        return utils.createReplyPacket(request,
+                                       {
+                                         statusCode: 200,
+                                         body:       'API response',
+                                       });
       });
 
       utils.get('/path/to/api')

  Modified: test/test-utils.js (+9 -0)
===================================================================
--- test/test-utils.js    2013-07-21 16:37:32 +0900 (bc3847e)
+++ test/test-utils.js    2013-07-21 16:59:47 +0900 (ed282cd)
@@ -330,6 +330,15 @@ function createPacket(message, tag) {
 }
 exports.createPacket = createPacket;
 
+function createReplyPacket(requestPacket, envelope) {
+  var tag = requestPacket[0];
+  var timestamp = Date.now();
+  var requestEnvelope = requestPacket[2];
+  var replyEnvelope = Object.create(envelope);
+  envelope.inReplyTo = requestEnvelope.id;
+  return [tag, timestamp, replyEnvelope];
+}
+exports.createReplyPacket = createReplyPacket;
 
 function TypeOf(typeString) {
   if (!(this instanceof TypeOf))
-------------- next part --------------
HTML����������������������������...
Download 



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