[Groonga-commit] groonga/express-kotoumi [master] test: Use fake connections instead of simple string literals

Back to archive index

YUKI Hiroshi null+****@clear*****
Mon Feb 4 12:11:24 JST 2013


YUKI Hiroshi	2013-02-04 12:11:24 +0900 (Mon, 04 Feb 2013)

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

  Log:
    test: Use fake connections instead of simple string literals

  Modified files:
    test/express-adaptor.test.js
    test/frontend-rest-handler.test.js

  Modified: test/express-adaptor.test.js (+12 -2)
===================================================================
--- test/express-adaptor.test.js    2013-02-04 11:56:03 +0900 (c655055)
+++ test/express-adaptor.test.js    2013-02-04 12:11:24 +0900 (f66f38c)
@@ -31,11 +31,20 @@ suite('Adaption for express application', function() {
       }
     });
 
+    function createFakeConnection() {
+      return {
+        emitMessage: function() {},
+        emit: function() {},
+        on: function() {}
+      };
+    }
+
     test('to the document root', function(done) {
+      var fakeConnection = createFakeConnection();
       var application = express();
       application.kotoumi({
         prefix:     '',
-        connection: 'fake connection',
+        connection: fakeConnection,
         handlers:   handlersFactory
       });
 
@@ -54,10 +63,11 @@ suite('Adaption for express application', function() {
     });
 
     test('under specified path', function(done) {
+      var fakeConnection = createFakeConnection();
       var application = express();
       application.kotoumi({
         prefix:     '/path/to/kotoumi',
-        connection: 'fake connection',
+        connection: fakeConnection,
         handlers:   handlersFactory
       });
       utils.setupServer(application)

  Modified: test/frontend-rest-handler.test.js (+15 -4)
===================================================================
--- test/frontend-rest-handler.test.js    2013-02-04 11:56:03 +0900 (bd76e6e)
+++ test/frontend-rest-handler.test.js    2013-02-04 12:11:24 +0900 (c2b61c3)
@@ -8,14 +8,23 @@ var restHandler = require('../lib/frontend/rest-handler');
 var Connection = require('../lib/backend/connection').Connection;
 
 suite('REST API', function() {
+  function createFakeConnection() {
+    return {
+      emitMessage: function() {},
+      emit: function() {},
+      on: function() {}
+    };
+  }
+
   test('registeration for given handlers', function() {
+    var fakeConnection = createFakeConnection();
     var mockedHandlers = nodemock.mock('search')
-          .takes('fake connection')
+          .takes(fakeConnection)
           .returns(function() {});
     var application = express();
     restHandler.register(application, {
       prefix:     '',
-      connection: 'fake connection',
+      connection: fakeConnection,
       handlers:   mockedHandlers
     });
     mockedHandlers.assertThrows();
@@ -43,10 +52,11 @@ suite('REST API', function() {
     });
 
     test('to the document root', function(done) {
+      var fakeConnection = createFakeConnection();
       var application = express();
       restHandler.register(application, {
         prefix:     '',
-        connection: 'fake connection',
+        connection: fakeConnection,
         handlers:   handlersFactory
       });
       utils.setupServer(application)
@@ -64,10 +74,11 @@ suite('REST API', function() {
     });
 
     test('under specified path', function(done) {
+      var fakeConnection = createFakeConnection();
       var application = express();
       restHandler.register(application, {
         prefix:     '/path/to/kotoumi',
-        connection: 'fake connection',
+        connection: fakeConnection,
         handlers:   handlersFactory
       });
       utils.setupServer(application)
-------------- next part --------------
HTML����������������������������...
Download 



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