diff options
author | Eric Avdey <eiri@eiri.ca> | 2017-06-19 15:11:16 -0300 |
---|---|---|
committer | Eric Avdey <eiri@eiri.ca> | 2017-06-23 18:03:05 +0000 |
commit | c7f7dcf380e9c90b0e656fa6f52125c574276b3e (patch) | |
tree | acbb02da7d80ee90937e6183b2596b2c6738a2a0 | |
parent | 2f539e003c88b8c76c42a39e6c53b9e61bc783f8 (diff) | |
download | couchdb-c7f7dcf380e9c90b0e656fa6f52125c574276b3e.tar.gz |
Fix "not_mocked" error in compaction tests
With meck unload set during per suit
teardown all the mocked modules crashing
with "not_mocked" error on attempt
to stop couch in the final cleanup.
This fix moves load and unload meck
modules into global setup and cleanup
-rw-r--r-- | src/couch/test/couchdb_compaction_daemon_tests.erl | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/couch/test/couchdb_compaction_daemon_tests.erl b/src/couch/test/couchdb_compaction_daemon_tests.erl index ba7396f36..09646b381 100644 --- a/src/couch/test/couchdb_compaction_daemon_tests.erl +++ b/src/couch/test/couchdb_compaction_daemon_tests.erl @@ -17,23 +17,27 @@ -define(TIMEOUT, 120000). -define(TIMEOUT_S, ?TIMEOUT div 1000). +-define(MODS_TO_MOCK, + [couch_db_updater, couch_mrview_compactor, couch_compaction_daemon]). start() -> Ctx = test_util:start_couch(), config:set("compaction_daemon", "check_interval", "3", false), config:set("compaction_daemon", "min_file_size", "100000", false), + ok = meck:new(?MODS_TO_MOCK, [passthrough]), Ctx. -setup() -> - ok = meck:new(couch_db_updater, [passthrough]), - ok = meck:new(couch_mrview_compactor, [passthrough]), - ok = meck:new(couch_compaction_daemon, [passthrough]), +stop(Ctx) -> + test_util:stop_couch(Ctx), + meck:unload(?MODS_TO_MOCK). +setup() -> DbName = ?tempdb(), {ok, Db} = couch_db:create(DbName, [?ADMIN_CTX]), create_design_doc(Db), ok = couch_db:close(Db), + meck:reset(?MODS_TO_MOCK), DbName. teardown(DbName) -> @@ -43,13 +47,7 @@ teardown(DbName) -> ok = config:delete("compactions", Key, false) end, Configs), - couch_server:delete(DbName, [?ADMIN_CTX]), - - (catch meck:unload(couch_compaction_daemon)), - (catch meck:unload(couch_mrview_compactor)), - (catch meck:unload(couch_db_updater)), - - ok. + couch_server:delete(DbName, [?ADMIN_CTX]). compaction_daemon_test_() -> @@ -57,7 +55,7 @@ compaction_daemon_test_() -> "Compaction daemon tests", { setup, - fun start/0, fun test_util:stop_couch/1, + fun start/0, fun stop/1, { foreach, fun setup/0, fun teardown/1, |