couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject [37/50] couchdb commit: updated refs/heads/1963-eunit to bfb7eb9
Date Mon, 16 Jun 2014 22:53:18 GMT
Port couch_mrview/04-index-info.t etap test suite to eunit


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

Branch: refs/heads/1963-eunit
Commit: 38b3ecf120091994f95a41b197bf822781fd7546
Parents: 093a10f
Author: Alexander Shorin <kxepal@apache.org>
Authored: Wed Jun 11 20:23:47 2014 +0400
Committer: Alexander Shorin <kxepal@apache.org>
Committed: Tue Jun 17 01:42:13 2014 +0400

----------------------------------------------------------------------
 src/couch_mrview/Makefile.am                    |  2 +-
 src/couch_mrview/test/04-index-info.t           | 54 ------------
 .../test/couch_mrview_index_info_tests.erl      | 87 ++++++++++++++++++++
 3 files changed, 88 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/38b3ecf1/src/couch_mrview/Makefile.am
----------------------------------------------------------------------
diff --git a/src/couch_mrview/Makefile.am b/src/couch_mrview/Makefile.am
index 59ee5fe..1aeee7f 100644
--- a/src/couch_mrview/Makefile.am
+++ b/src/couch_mrview/Makefile.am
@@ -33,10 +33,10 @@ source_files = \
     src/couch_mrview_util.erl
 
 test_files = \
+    test/couch_mrview_index_info_tests.erl \
     test/couch_mrview_map_views_tests.erl \
     test/couch_mrview_modules_load_tests.erl \
     test/couch_mrview_red_views_tests.erl \
-    test/04-index-info.t \
     test/05-collation.t \
     test/06-all-docs.t \
 	test/07-compact-swap.t

http://git-wip-us.apache.org/repos/asf/couchdb/blob/38b3ecf1/src/couch_mrview/test/04-index-info.t
----------------------------------------------------------------------
diff --git a/src/couch_mrview/test/04-index-info.t b/src/couch_mrview/test/04-index-info.t
deleted file mode 100644
index 6b67b56..0000000
--- a/src/couch_mrview/test/04-index-info.t
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/usr/bin/env escript
-%% -*- erlang -*-
-
-% Licensed under the Apache License, Version 2.0 (the "License"); you may not
-% use this file except in compliance with the License. You may obtain a copy of
-% the License at
-%
-%   http://www.apache.org/licenses/LICENSE-2.0
-%
-% Unless required by applicable law or agreed to in writing, software
-% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-% License for the specific language governing permissions and limitations under
-% the License.
-
-main(_) ->
-    test_util:init_code_path(),
-
-    etap:plan(9),
-    case (catch test()) of
-        ok ->
-            etap:end_tests();
-        Other ->
-            etap:diag(io_lib:format("Test died abnormally: ~p", [Other])),
-            etap:bail(Other)
-    end,
-    timer:sleep(300),
-    ok.
-
-sig() -> <<"276df562b152b3c4e5d34024f62672ed">>.
-
-test() ->
-    couch_server_sup:start_link(test_util:config_files()),
-
-    {ok, Db} = couch_mrview_test_util:init_db(<<"foo">>, map),
-    couch_mrview:query_view(Db, <<"_design/bar">>, <<"baz">>),
-
-    {ok, Info} = couch_mrview:get_info(Db, <<"_design/bar">>),
-
-    etap:is(getval(signature, Info), sig(), "Signature is ok."),
-    etap:is(getval(language, Info), <<"javascript">>, "Language is ok."),
-    etap:is_greater(getval(disk_size, Info), 0, "Disk size is ok."),
-    etap:is_greater(getval(data_size, Info), 0, "Data size is ok."),
-    etap:is(getval(update_seq, Info), 11, "Update seq is ok."),
-    etap:is(getval(purge_seq, Info), 0, "Purge seq is ok."),
-    etap:is(getval(updater_running, Info), false, "No updater running."),
-    etap:is(getval(compact_running, Info), false, "No compaction running."),
-    etap:is(getval(waiting_clients, Info), 0, "No waiting clients."),
-
-    ok.
-
-getval(Key, PL) ->
-    {value, {Key, Val}} = lists:keysearch(Key, 1, PL),
-    Val.

http://git-wip-us.apache.org/repos/asf/couchdb/blob/38b3ecf1/src/couch_mrview/test/couch_mrview_index_info_tests.erl
----------------------------------------------------------------------
diff --git a/src/couch_mrview/test/couch_mrview_index_info_tests.erl b/src/couch_mrview/test/couch_mrview_index_info_tests.erl
new file mode 100644
index 0000000..0867a72
--- /dev/null
+++ b/src/couch_mrview/test/couch_mrview_index_info_tests.erl
@@ -0,0 +1,87 @@
+% Licensed under the Apache License, Version 2.0 (the "License"); you may not
+% use this file except in compliance with the License. You may obtain a copy of
+% the License at
+%
+%   http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+% License for the specific language governing permissions and limitations under
+% the License.
+
+-module(couch_mrview_index_info_tests).
+
+-include("../../../test/couchdb/couch_eunit.hrl").
+-include_lib("couchdb/couch_db.hrl").
+
+-define(ADMIN_USER, {user_ctx, #user_ctx{roles=[<<"_admin">>]}}).
+-define(TIMEOUT, 1000).
+
+
+start() ->
+    {ok, Pid} = couch_server_sup:start_link(?CONFIG_CHAIN),
+    Pid.
+
+stop(Pid) ->
+    erlang:monitor(process, Pid),
+    couch_server_sup:stop(),
+    receive
+        {'DOWN', _, _, Pid, _} ->
+            ok
+    after ?TIMEOUT ->
+        throw({timeout, server_stop})
+    end.
+
+setup() ->
+    {ok, Db} = couch_mrview_test_util:init_db(?tempdb(), map),
+    couch_mrview:query_view(Db, <<"_design/bar">>, <<"baz">>),
+    {ok, Info} = couch_mrview:get_info(Db, <<"_design/bar">>),
+    {Db, Info}.
+
+teardown({Db, _}) ->
+    couch_db:close(Db),
+    couch_server:delete(Db#db.name, [?ADMIN_USER]),
+    ok.
+
+
+view_info_test_() ->
+    {
+        "Views index tests",
+        {
+            setup,
+            fun start/0, fun stop/1,
+            {
+                foreach,
+                fun setup/0, fun teardown/1,
+                [
+                    fun should_get_property/1
+                ]
+            }
+        }
+    }.
+
+
+should_get_property({_, Info}) ->
+    InfoProps = [
+        {signature, <<"276df562b152b3c4e5d34024f62672ed">>},
+        {language, <<"javascript">>},
+        {disk_size, 314},
+        {data_size, 263},
+        {update_seq, 11},
+        {purge_seq, 0},
+        {updater_running, false},
+        {compact_running, false},
+        {waiting_clients, 0}
+    ],
+    [
+        {atom_to_list(Key), ?_assertEqual(Val, getval(Key, Info))}
+        || {Key, Val} <- InfoProps
+    ].
+
+
+getval(Key, PL) ->
+    {value, {Key, Val}} = lists:keysearch(Key, 1, PL),
+    Val.
+
+


Mime
View raw message