From e607d789ae3d41d1533809faa947788668b38f44 Mon Sep 17 00:00:00 2001 From: JD Bothma Date: Tue, 4 Mar 2014 19:54:39 +0100 Subject: [PATCH] Ensure apps are stopped and started properly before and after tests --- src/lhttpc.app.src | 2 +- test/lhttpc_manager_tests.erl | 12 +++++++++--- test/lhttpc_tests.erl | 18 +++++++++++------- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/lhttpc.app.src b/src/lhttpc.app.src index 1c3d93bb..f4297c11 100644 --- a/src/lhttpc.app.src +++ b/src/lhttpc.app.src @@ -32,7 +32,7 @@ {vsn, "1.3.0"}, {modules, []}, {registered, [lhttpc_manager]}, - {applications, [kernel, stdlib, ssl, crypto]}, + {applications, [kernel, stdlib, ssl, crypto, public_key]}, {mod, {lhttpc, nil}}, {env, [{connection_timeout, 300000}, {pool_size, 50}]} ]}. diff --git a/test/lhttpc_manager_tests.erl b/test/lhttpc_manager_tests.erl index 4e24afe0..fd29a880 100644 --- a/test/lhttpc_manager_tests.erl +++ b/test/lhttpc_manager_tests.erl @@ -36,15 +36,21 @@ %%% Eunit setup stuff start_app() -> - application:start(public_key), + ok = application:start(asn1), + ok = application:start(public_key), ok = application:start(ssl), - _ = application:load(lhttpc), + case application:load(lhttpc) of + ok -> ok; + {error, {already_loaded, lhttpc}} -> ok + end, ok = application:set_env(lhttpc, pool_size, 3), ok = application:start(lhttpc). stop_app(_) -> ok = application:stop(lhttpc), - ok = application:stop(ssl). + ok = application:stop(ssl), + ok = application:stop(public_key), + ok = application:stop(asn1). manager_test_() -> {inorder, diff --git a/test/lhttpc_tests.erl b/test/lhttpc_tests.erl index 7b6b809a..a459df6f 100644 --- a/test/lhttpc_tests.erl +++ b/test/lhttpc_tests.erl @@ -99,14 +99,18 @@ test_no(N, Tests) -> %%% Eunit setup stuff start_app() -> - application:start(crypto), - application:start(public_key), - ok = application:start(ssl), - ok = lhttpc:start(). - -stop_app(_) -> + AppsToStart = [asn1, public_key, ssl], + lists:map(fun(App) -> + ok = application:start(App) + end, AppsToStart), + ok = lhttpc:start(), + AppsToStart. + +stop_app(StartedApps) -> ok = lhttpc:stop(), - ok = application:stop(ssl). + lists:map(fun(App) -> + ok = application:stop(App) + end, lists:reverse(StartedApps)). tcp_test_() -> {inorder,