diff options
author | Paul J. Davis <paul.joseph.davis@gmail.com> | 2019-12-25 11:38:36 -0600 |
---|---|---|
committer | Paul J. Davis <paul.joseph.davis@gmail.com> | 2019-12-25 13:52:32 -0600 |
commit | b00ea30457ee6d78fe8de7c8d124a1c6f4eee725 (patch) | |
tree | be942716142cc9322174c0f5d3bbd5b9a4b9ea8c | |
parent | dc4887eb6dcefe07b48229b0ddc9aa6aeb62f514 (diff) | |
download | couchdb-b00ea30457ee6d78fe8de7c8d124a1c6f4eee725.tar.gz |
Speedup eunit: couch_replicator_auth_session
-rw-r--r-- | src/couch_replicator/src/couch_replicator_auth_session.erl | 57 |
1 files 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 51efd2af8..30f499a33 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). |