[Groonga-commit] droonga/express-droonga at 1b22d94 [master] Add tests for cache entry

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Mar 20 15:33:42 JST 2014


YUKI Hiroshi	2014-03-20 15:33:42 +0900 (Thu, 20 Mar 2014)

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

  Message:
    Add tests for cache entry

  Added files:
    test/response-cache/entry.test.js

  Added: test/response-cache/entry.test.js (+37 -0) 100644
===================================================================
--- /dev/null
+++ test/response-cache/entry.test.js    2014-03-20 15:33:42 +0900 (e7aa3b5)
@@ -0,0 +1,37 @@
+var assert = require('chai').assert;
+var nodemock = require('nodemock');
+
+var Entry = require('../../lib/response-cache/entry');
+
+suite('Response Cache Entry', function() {
+  suite('isCachable', function() {
+    test('not processed', function() {
+      var entry = new Entry('key', 10, {});
+      assert.isFalse(entry.isCachable());
+    });
+
+    test('success', function() {
+      var entry = new Entry('key', 10, {});
+      entry.data.status = 200;
+      assert.isTrue(entry.isCachable());
+    });
+
+    test('error', function() {
+      var entry = new Entry('key', 10, {});
+      entry.data.status = 400;
+      assert.isFalse(entry.isCachable());
+    });
+  });
+
+  test('store', function() {
+    var ttl = 10;
+    var value = true;
+    var mockedStorage = nodemock.mock('set').takes('key', { status: 200, headers: {}, body: [] }, ttl);
+
+    var entry = new Entry('key', ttl, mockedStorage);
+    entry.data.status = 200;
+    entry.store();
+    mockedStorage.assertThrows();
+  });
+});
+
-------------- next part --------------
HTML����������������������������...
Download 



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