[Groonga-commit] droonga/express-droonga at e6c8cc1 [master] Add tests for Cache#getRule about matched cases

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Mar 20 16:51:37 JST 2014


YUKI Hiroshi	2014-03-20 16:51:37 +0900 (Thu, 20 Mar 2014)

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

  Message:
    Add tests for Cache#getRule about matched cases

  Modified files:
    test/response-cache/cache.test.js

  Modified: test/response-cache/cache.test.js (+33 -0)
===================================================================
--- test/response-cache/cache.test.js    2014-03-20 16:48:18 +0900 (f0e7baf)
+++ test/response-cache/cache.test.js    2014-03-20 16:51:37 +0900 (bbdbd21)
@@ -51,6 +51,39 @@ suite('Response Cache', function() {
       var rule = cache.getRule(stubRequest);
       assert.isNull(rule);
     });
+
+    test('mached to a rule', function() {
+      var cache = new Cache({
+        rules: [
+          { regex: /foo/ }
+        ]
+      });
+      var stubRequest = {
+        method: 'GET',
+        url:    'fooooo'
+      };
+      var rule = cache.getRule(stubRequest);
+      assert.isNotNull(rule);
+      assert.deepEqual(rule.regex, /foo/);
+    });
+
+    test('mached to multiple rules', function() {
+      var primaryRegex = /foo/;
+      var secondaryRegex = /foobar/;
+      var cache = new Cache({
+        rules: [
+          { regex: primaryRegex },
+          { regex: secondaryRegex },
+        ]
+      });
+      var stubRequest = {
+        method: 'GET',
+        url:    'foobar'
+      };
+      var rule = cache.getRule(stubRequest);
+      assert.isNotNull(rule);
+      assert.deepEqual(rule.regex, primaryRegex);
+    });
   });
 });
 
-------------- next part --------------
HTML����������������������������...
Download 



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