You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by kx...@apache.org on 2015/09/30 15:49:04 UTC

[2/2] couch commit: updated refs/heads/master to 269faca

Turn couch_doc_json_tests into unit tests

There are two issues:
1. There is no any reason to start server instance to ensure that we
accepts valid decoded JSON objects and throw right errors on bad ones;
2. Tests get actually executed before setup/0 call


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/7477e58a
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/7477e58a
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/7477e58a

Branch: refs/heads/master
Commit: 7477e58a5117f9b9bd1eb94c252377809558f2eb
Parents: 100bb30
Author: Alexander Shorin <kx...@apache.org>
Authored: Tue Sep 29 16:42:18 2015 +0300
Committer: Alexander Shorin <kx...@apache.org>
Committed: Wed Sep 30 16:45:06 2015 +0300

----------------------------------------------------------------------
 test/couch_doc_json_tests.erl | 46 +++++++++++++++++++++++++-------------
 1 file changed, 30 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/7477e58a/test/couch_doc_json_tests.erl
----------------------------------------------------------------------
diff --git a/test/couch_doc_json_tests.erl b/test/couch_doc_json_tests.erl
index 56587cd..165771c 100644
--- a/test/couch_doc_json_tests.erl
+++ b/test/couch_doc_json_tests.erl
@@ -16,25 +16,39 @@
 -include_lib("couch/include/couch_db.hrl").
 
 
+setup() ->
+    mock(couch_log),
+    mock(couch_db_plugin),
+    ok.
+
+teardown(_) ->
+    meck:unload(couch_log),
+    meck:unload(couch_db_plugin),
+    ok.
+
+mock(couch_db_plugin) ->
+    ok = meck:new(couch_db_plugin, [passthrough]),
+    ok = meck:expect(couch_db_plugin, validate_docid, fun(_) -> false end),
+    ok;
+mock(couch_log) ->
+    ok = meck:new(couch_log, [passthrough]),
+    ok = meck:expect(couch_log, debug, fun(_, _) -> ok end),
+    ok.
+
+
 json_doc_test_() ->
     {
         setup,
-        fun() -> test_util:start(?MODULE) end, fun test_util:stop/1,
-        [
-            {
-                "Document from JSON",
-                [
-                    from_json_success_cases(),
-                    from_json_error_cases()
-                ]
-            },
-            {
-                "Document to JSON",
-                [
-                    to_json_success_cases()
-                ]
-            }
-        ]
+        fun setup/0, fun teardown/1,
+        fun(_) ->
+            [{"Document from JSON", [
+                from_json_success_cases(),
+                from_json_error_cases()
+             ]},
+             {"Document to JSON", [
+                 to_json_success_cases()
+             ]}]
+        end
     }.
 
 from_json_success_cases() ->