summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul J. Davis <paul.joseph.davis@gmail.com>2019-12-19 13:31:20 -0600
committerPaul J. Davis <paul.joseph.davis@gmail.com>2019-12-25 13:52:32 -0600
commit97c2e856efef43a18a882ad70f2456ec08f6f698 (patch)
treee3ebfbb40eadc96bdeddbd48614e1eae4477673e
parent6caca795dd3d7ae82d08b39039c07b9e331bb311 (diff)
downloadcouchdb-97c2e856efef43a18a882ad70f2456ec08f6f698.tar.gz
Speedup eunit: couch_replicator_doc_processor
Another example of moving mocks around.
-rw-r--r--src/couch_replicator/src/couch_replicator_doc_processor.erl68
1 files changed, 45 insertions, 23 deletions
diff --git a/src/couch_replicator/src/couch_replicator_doc_processor.erl b/src/couch_replicator/src/couch_replicator_doc_processor.erl
index 29170ed53..6778d537d 100644
--- a/src/couch_replicator/src/couch_replicator_doc_processor.erl
+++ b/src/couch_replicator/src/couch_replicator_doc_processor.erl
@@ -614,25 +614,30 @@ cluster_membership_foldl(#rdoc{id = {DbName, DocId} = Id, rid = RepId}, nil) ->
doc_processor_test_() ->
{
- foreach,
- fun setup/0,
- fun teardown/1,
- [
- t_bad_change(),
- t_regular_change(),
- t_change_with_doc_processor_crash(),
- t_change_with_existing_job(),
- t_deleted_change(),
- t_triggered_change(),
- t_completed_change(),
- t_active_replication_completed(),
- t_error_change(),
- t_failed_change(),
- t_change_for_different_node(),
- t_change_when_cluster_unstable(),
- t_ejson_docs(),
- t_cluster_membership_foldl()
- ]
+ setup,
+ fun setup_all/0,
+ fun teardown_all/1,
+ {
+ foreach,
+ fun setup/0,
+ fun teardown/1,
+ [
+ t_bad_change(),
+ t_regular_change(),
+ t_change_with_doc_processor_crash(),
+ t_change_with_existing_job(),
+ t_deleted_change(),
+ t_triggered_change(),
+ t_completed_change(),
+ t_active_replication_completed(),
+ t_error_change(),
+ t_failed_change(),
+ t_change_for_different_node(),
+ t_change_when_cluster_unstable(),
+ t_ejson_docs(),
+ t_cluster_membership_foldl()
+ ]
+ }
}.
@@ -829,7 +834,7 @@ get_worker_ref_test_() ->
% Test helper functions
-setup() ->
+setup_all() ->
meck:expect(couch_log, info, 2, ok),
meck:expect(couch_log, notice, 2, ok),
meck:expect(couch_log, warning, 2, ok),
@@ -845,15 +850,32 @@ setup() ->
end),
meck:expect(couch_replicator_scheduler, remove_job, 1, ok),
meck:expect(couch_replicator_docs, remove_state_fields, 2, ok),
- meck:expect(couch_replicator_docs, update_failed, 3, ok),
+ meck:expect(couch_replicator_docs, update_failed, 3, ok).
+
+
+teardown_all(_) ->
+ meck:unload().
+
+
+setup() ->
+ meck:reset([
+ config,
+ couch_log,
+ couch_replicator_clustering,
+ couch_replicator_doc_processor_worker,
+ couch_replicator_docs,
+ couch_replicator_scheduler
+ ]),
+ % Set this expectation back to the default for
+ % each test since some tests change it
+ meck:expect(couch_replicator_clustering, owner, 2, node()),
{ok, Pid} = start_link(),
unlink(Pid),
Pid.
teardown(Pid) ->
- exit(Pid, kill),
- meck:unload().
+ exit(Pid, kill).
removed_state_fields() ->