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 2017/07/18 16:32:22 UTC
[couchdb] branch master updated: Fix test teardown
This is an automated email from the ASF dual-hosted git repository.
davisp pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git
The following commit(s) were added to refs/heads/master by this push:
new 0bea3a4 Fix test teardown
0bea3a4 is described below
commit 0bea3a40c230e9a7f7932d4f97a5f441287bdb78
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Tue Jul 18 10:51:41 2017 -0500
Fix test teardown
We weren't stopping the correct set of applications as well as
forgetting to unload meck. I've also changed the test generators so that
they execute all of the provided assertions.
Fix #687
---
src/mango/src/mango_idx_text.erl | 56 ++++++++++++++++++++++------------------
1 file changed, 31 insertions(+), 25 deletions(-)
diff --git a/src/mango/src/mango_idx_text.erl b/src/mango/src/mango_idx_text.erl
index ad9d2e8..4710d5f 100644
--- a/src/mango/src/mango_idx_text.erl
+++ b/src/mango/src/mango_idx_text.erl
@@ -367,7 +367,7 @@ forbid_index_all() ->
setup() ->
- test_util:start_couch(),
+ Ctx = test_util:start_couch(),
meck:expect(couch_log, warning, 2,
fun(_,_) ->
throw({test_error, logged_warning})
@@ -375,12 +375,12 @@ setup() ->
%default index all def that generates {fields, all_fields}
Index = #idx{def={[]}},
Db = #db{name = <<"testdb">>, user_ctx=#user_ctx{name = <<"u1">>}},
- {Index, Db}.
+ {Index, Db, Ctx}.
-teardown(_) ->
- ok = config:delete("mango", "index_all_disabled"),
- test_util:stop_couch().
+teardown({_, _, Ctx}) ->
+ meck:unload(),
+ test_util:stop_couch(Ctx).
index_all_test_() ->
@@ -397,26 +397,32 @@ index_all_test_() ->
}.
-forbid_index_all({Idx, Db}) ->
- ok = config:set("mango", "index_all_disabled", "true"),
- ?_assertThrow({mango_error, ?MODULE, index_all_disabled},
- validate_new(Idx, Db)
- ).
-
-
-default_and_false_index_all({Idx, Db}) ->
- {ok, #idx{def={Def}}} = validate_new(Idx, Db),
- Fields = couch_util:get_value(fields, Def),
- ?_assertEqual(all_fields, Fields),
- ok = config:set("mango", "index_all_disabled", "false"),
- {ok, #idx{def={Def2}}} = validate_new(Idx, Db),
- Fields2 = couch_util:get_value(fields, Def2),
- ?_assertEqual(all_fields, Fields2).
-
-
-warn_index_all({Idx, Db}) ->
- ok = config:set("mango", "index_all_disabled", "warn"),
- ?_assertThrow({test_error, logged_warning}, validate_new(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},
+ validate_new(Idx, Db)
+ )
+ end).
+
+
+default_and_false_index_all({Idx, Db, _}) ->
+ ?_test(begin
+ {ok, #idx{def={Def}}} = validate_new(Idx, Db),
+ Fields = couch_util:get_value(fields, Def),
+ ?assertEqual(all_fields, Fields),
+ ok = config:set("mango", "index_all_disabled", "false", false),
+ {ok, #idx{def={Def2}}} = validate_new(Idx, Db),
+ Fields2 = couch_util:get_value(fields, Def2),
+ ?assertEqual(all_fields, Fields2)
+ end).
+
+
+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))
+ end).
-endif.
--
To stop receiving notification emails like this one, please contact
['"commits@couchdb.apache.org" <co...@couchdb.apache.org>'].