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:29 UTC
[couchdb] 26/41: Speedup eunit: couch_mrview_compactor
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 337e848ce1d4dec7aad2f513ce7e9f321efca57b
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Wed Dec 25 11:37:19 2019 -0600
Speedup eunit: couch_mrview_compactor
---
src/couch_mrview/src/couch_mrview_compactor.erl | 41 +++++++++++++------------
1 file changed, 22 insertions(+), 19 deletions(-)
diff --git a/src/couch_mrview/src/couch_mrview_compactor.erl b/src/couch_mrview/src/couch_mrview_compactor.erl
index 17d67f1..d42edc0 100644
--- a/src/couch_mrview/src/couch_mrview_compactor.erl
+++ b/src/couch_mrview/src/couch_mrview_compactor.erl
@@ -248,11 +248,23 @@ remove_compacted(#mrst{sig = Sig, db_name = DbName} = State) ->
-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").
+setup_all() ->
+ meck:new(couch_index_updater),
+ meck:new(couch_log).
+
+teardown_all(_) ->
+ meck:unload().
+
recompact_test_() ->
- [
- recompact_success_after_progress(),
- recompact_exceeded_retry_count()
- ].
+ {
+ setup,
+ fun setup_all/0,
+ fun teardown_all/1,
+ [
+ recompact_success_after_progress(),
+ recompact_exceeded_retry_count()
+ ]
+ }.
recompact_success_after_progress() ->
?_test(begin
@@ -262,12 +274,8 @@ recompact_success_after_progress() ->
timer:sleep(100),
exit({updated, self(), State#mrst{update_seq = 2}})
end),
- try
- State = #mrst{fd=self(), update_seq=0},
- ?assertEqual({ok, State#mrst{update_seq = 2}}, recompact(State))
- after
- meck:unload(couch_index_updater)
- end
+ State = #mrst{fd=self(), update_seq=0},
+ ?assertEqual({ok, State#mrst{update_seq = 2}}, recompact(State))
end).
recompact_exceeded_retry_count() ->
@@ -277,15 +285,10 @@ recompact_exceeded_retry_count() ->
exit(error)
end),
ok = meck:expect(couch_log, warning, fun(_, _) -> ok end),
- try
- State = #mrst{fd=self(), db_name=foo, idx_name=bar},
- ExpectedError = {exceeded_recompact_retry_count,
- [{db_name, foo}, {idx_name, bar}]},
- ?assertError(ExpectedError, recompact(State))
- after
- meck:unload(couch_log),
- meck:unload(couch_index_updater)
- end
+ State = #mrst{fd=self(), db_name=foo, idx_name=bar},
+ ExpectedError = {exceeded_recompact_retry_count,
+ [{db_name, foo}, {idx_name, bar}]},
+ ?assertError(ExpectedError, recompact(State))
end).
-endif.