You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2019/12/25 17:45:40 UTC
[couchdb] 37/41: Speedup eunit: mango_idx_test
This is an automated email from the ASF dual-hosted git repository.
davisp pushed a commit to branch speedup-test-suite
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 59eaef05328bda5a0c35b069e210099cea74d9d8
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Wed Dec 25 11:42:01 2019 -0600
Speedup eunit: mango_idx_test
---
src/mango/src/mango_idx_text.erl | 47 +++++++++++++++++++++++++---------------
1 file changed, 30 insertions(+), 17 deletions(-)
diff --git a/src/mango/src/mango_idx_text.erl b/src/mango/src/mango_idx_text.erl
index 0b78e88..50f6cc8 100644
--- a/src/mango/src/mango_idx_text.erl
+++ b/src/mango/src/mango_idx_text.erl
@@ -381,40 +381,52 @@ forbid_index_all() ->
-include_lib("eunit/include/eunit.hrl").
-setup() ->
+setup_all() ->
Ctx = test_util:start_couch(),
meck:expect(couch_log, warning, 2,
fun(_,_) ->
throw({test_error, logged_warning})
end),
+ Ctx.
+
+
+teardown_all(Ctx) ->
+ meck:unload(),
+ test_util:stop_couch(Ctx).
+
+
+setup() ->
%default index all def that generates {fields, all_fields}
Index = #idx{def={[]}},
DbName = <<"testdb">>,
UserCtx = #user_ctx{name = <<"u1">>},
{ok, Db} = couch_db:clustered_db(DbName, UserCtx),
- {Index, Db, Ctx}.
+ {Index, Db}.
-teardown({_, _, Ctx}) ->
- meck:unload(),
- test_util:stop_couch(Ctx).
+teardown(_) ->
+ ok.
index_all_test_() ->
{
- foreach,
- fun setup/0,
- fun teardown/1,
- [
- fun forbid_index_all/1,
- fun default_and_false_index_all/1,
- fun warn_index_all/1
- ]
-
+ setup,
+ fun setup_all/0,
+ fun teardown_all/1,
+ {
+ foreach,
+ fun setup/0,
+ fun teardown/1,
+ [
+ fun forbid_index_all/1,
+ fun default_and_false_index_all/1,
+ fun warn_index_all/1
+ ]
+ }
}.
-forbid_index_all({Idx, Db, _}) ->
+forbid_index_all({Idx, Db}) ->
?_test(begin
ok = config:set("mango", "index_all_disabled", "true", false),
?assertThrow({mango_error, ?MODULE, index_all_disabled},
@@ -423,8 +435,9 @@ forbid_index_all({Idx, Db, _}) ->
end).
-default_and_false_index_all({Idx, Db, _}) ->
+default_and_false_index_all({Idx, Db}) ->
?_test(begin
+ config:delete("mango", "index_all_disabled", false),
{ok, #idx{def={Def}}} = validate_new(Idx, Db),
Fields = couch_util:get_value(fields, Def),
?assertEqual(all_fields, Fields),
@@ -435,7 +448,7 @@ default_and_false_index_all({Idx, Db, _}) ->
end).
-warn_index_all({Idx, Db, _}) ->
+warn_index_all({Idx, Db}) ->
?_test(begin
ok = config:set("mango", "index_all_disabled", "warn", false),
?assertThrow({test_error, logged_warning}, validate_new(Idx, Db))