Created
May 18, 2010 05:14
-
-
Save moonpolysoft/404645 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(test_helper). | |
-export([riak_test/1]). | |
riak_test(Fun) -> | |
start_riak(), | |
{ok, Riak} = riak:local_client(), | |
Ret = (catch Fun(Riak)), | |
stop_riak(), | |
case Ret of | |
{'EXIT', Err} -> throw(Err); | |
_ -> Ret | |
end. | |
start_riak() -> | |
% Dir = "/tmp/ring-" ++ os:getpid(), | |
% filelib:ensure_dir(Dir ++ "/"), | |
% application:set_env(riak_core, ring_state_dir, Dir), | |
application:set_env(riak_kv, storage_backend, riak_kv_cache_backend), | |
load_and_start_apps([kernel, stdlib, sasl, crypto, webmachine, | |
riak_core, riak_kv]). | |
stop_riak() -> | |
application:stop(riak_kv), | |
application:stop(riak_core). | |
load_and_start_apps([]) -> ok; | |
load_and_start_apps([App|Tail]) -> | |
application:load(App), | |
application:start(App), | |
load_and_start_apps(Tail). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment