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:32 UTC
[couchdb] 29/41: Speedup eunit: couch_replicator_auth_session
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 6c4e9ae481497b667364ba4b7c089ea27d985578
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Wed Dec 25 11:38:36 2019 -0600
Speedup eunit: couch_replicator_auth_session
---
.../src/couch_replicator_auth_session.erl | 57 ++++++++++++++--------
1 file changed, 37 insertions(+), 20 deletions(-)
diff --git a/src/couch_replicator/src/couch_replicator_auth_session.erl b/src/couch_replicator/src/couch_replicator_auth_session.erl
index 51efd2a..30f499a 100644
--- a/src/couch_replicator/src/couch_replicator_auth_session.erl
+++ b/src/couch_replicator/src/couch_replicator_auth_session.erl
@@ -631,24 +631,29 @@ extract_creds_success_test_() ->
cookie_update_test_() ->
{
- foreach,
- fun setup/0,
- fun teardown/1,
- [
- t_do_refresh_without_max_age(),
- t_do_refresh_with_max_age(),
- t_dont_refresh(),
- t_process_auth_failure(),
- t_process_auth_failure_stale_epoch(),
- t_process_auth_failure_too_frequent(),
- t_process_ok_update_cookie(),
- t_process_ok_no_cookie(),
- t_init_state_fails_on_401(),
- t_init_state_401_with_require_valid_user(),
- t_init_state_404(),
- t_init_state_no_creds(),
- t_init_state_http_error()
- ]
+ setup,
+ fun setup_all/0,
+ fun teardown_all/1,
+ {
+ foreach,
+ fun setup/0,
+ fun teardown/1,
+ [
+ t_do_refresh_without_max_age(),
+ t_do_refresh_with_max_age(),
+ t_dont_refresh(),
+ t_process_auth_failure(),
+ t_process_auth_failure_stale_epoch(),
+ t_process_auth_failure_too_frequent(),
+ t_process_ok_update_cookie(),
+ t_process_ok_no_cookie(),
+ t_init_state_fails_on_401(),
+ t_init_state_401_with_require_valid_user(),
+ t_init_state_404(),
+ t_init_state_no_creds(),
+ t_init_state_http_error()
+ ]
+ }
}.
@@ -774,7 +779,7 @@ t_init_state_http_error() ->
end).
-setup() ->
+setup_all() ->
meck:expect(couch_replicator_httpc_pool, get_worker, 1, {ok, worker}),
meck:expect(couch_replicator_httpc_pool, release_worker_sync, 2, ok),
meck:expect(config, get, fun(_, _, Default) -> Default end),
@@ -782,10 +787,22 @@ setup() ->
ok.
-teardown(_) ->
+teardown_all(_) ->
meck:unload().
+setup() ->
+ meck:reset([
+ config,
+ couch_replicator_httpc_pool,
+ ibrowse
+ ]).
+
+
+teardown(_) ->
+ ok.
+
+
mock_http_cookie_response(Cookie) ->
Resp = {ok, "200", [{"Set-Cookie", "AuthSession=" ++ Cookie}], []},
meck:expect(ibrowse, send_req_direct, 7, Resp).