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:03 UTC

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

Repository: couchdb-couch
Updated Branches:
  refs/heads/master 100bb301c -> 269faca76


Fix tests for 8bbfba7 commit


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

Branch: refs/heads/master
Commit: 269faca764c8beeafc80b8c7f9b97da422673462
Parents: 7477e58
Author: Alexander Shorin <kx...@apache.org>
Authored: Tue Sep 29 16:44:23 2015 +0300
Committer: Alexander Shorin <kx...@apache.org>
Committed: Wed Sep 30 16:45:06 2015 +0300

----------------------------------------------------------------------
 test/couch_doc_json_tests.erl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/269faca7/test/couch_doc_json_tests.erl
----------------------------------------------------------------------
diff --git a/test/couch_doc_json_tests.erl b/test/couch_doc_json_tests.erl
index 165771c..ae4d73c 100644
--- a/test/couch_doc_json_tests.erl
+++ b/test/couch_doc_json_tests.erl
@@ -181,12 +181,12 @@ from_json_error_cases() ->
         },
         {
             {[{<<"_id">>, {[{<<"foo">>, 5}]}}]},
-            {bad_request, <<"Document id must be a string">>},
+            {illegal_docid, <<"Document id must be a string">>},
             "Document id must be a string."
         },
         {
             {[{<<"_id">>, <<"_random">>}]},
-            {bad_request,
+            {illegal_docid,
              <<"Only reserved document ids may start with underscore.">>},
             "Disallow arbitrary underscore prefixed docids."
         },


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

Posted by kx...@apache.org.
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() ->