Improve test setup and teardown
Project: http://git-wip-us.apache.org/repos/asf/couchdb-peruser/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-peruser/commit/a7e74f02 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-peruser/tree/a7e74f02 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-peruser/diff/a7e74f02 Branch: refs/heads/master Commit: a7e74f02f49c597ce06a55aabb0080965b0e46c9 Parents: 888a5bd Author: Klaus Trainer <[email protected]> Authored: Wed Aug 19 11:39:21 2015 +0200 Committer: Klaus Trainer <[email protected]> Committed: Wed Aug 19 11:39:21 2015 +0200 ---------------------------------------------------------------------- test/couchdb_peruser_test.erl | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-peruser/blob/a7e74f02/test/couchdb_peruser_test.erl ---------------------------------------------------------------------- diff --git a/test/couchdb_peruser_test.erl b/test/couchdb_peruser_test.erl index 57a369b..554f55b 100644 --- a/test/couchdb_peruser_test.erl +++ b/test/couchdb_peruser_test.erl @@ -18,15 +18,17 @@ -define(ADMIN_USERNAME, "admin"). -define(ADMIN_PASSWORD, "secret"). -start_couch() -> - test_util:start_couch([chttpd]). +setup_all() -> + TestCtx = test_util:start_couch([chttpd]), + config:set("admins", ?ADMIN_USERNAME, ?ADMIN_PASSWORD), + TestCtx. -stop_couch(TestCtx) -> +teardown_all(TestCtx) -> + config:delete("admins", ?ADMIN_USERNAME), test_util:stop_couch(TestCtx). setup() -> TestAuthDb = ?tempdb(), - config:set("admins", ?ADMIN_USERNAME, ?ADMIN_PASSWORD), do_request(put, get_base_url() ++ "/" ++ ?b2l(TestAuthDb)), set_config("couch_httpd_auth", "authentication_db", ?b2l(TestAuthDb)), set_config("couchdb_peruser", "enable", "true"), @@ -39,8 +41,7 @@ teardown(TestAuthDb) -> do_request(delete, get_base_url() ++ "/" ++ ?b2l(TestAuthDb)), lists:foreach(fun (DbName) -> delete_db(DbName) - end, all_dbs()), - config:delete("admins", ?ADMIN_USERNAME). + end, all_dbs()). set_config(Section, Key, Value) -> Url = lists:concat([ @@ -254,7 +255,7 @@ couchdb_peruser_test_() -> "couchdb_peruser test", { setup, - fun start_couch/0, fun stop_couch/1, + fun setup_all/0, fun teardown_all/1, { foreach, fun setup/0, fun teardown/1,
