From: Siraaj Khandkar Date: Wed, 13 Aug 2014 13:46:47 +0000 (-0400) Subject: Test pipe failure in addition to success. X-Git-Tag: 1.0.0~13 X-Git-Url: https://git.xandkar.net/?a=commitdiff_plain;h=126c888082556366e73dfa5fb5fe3eedf2818dfc;p=hope.git Test pipe failure in addition to success. --- diff --git a/test/hope_result_SUITE.erl b/test/hope_result_SUITE.erl index 3c0a6ec..de6a7bb 100644 --- a/test/hope_result_SUITE.erl +++ b/test/hope_result_SUITE.erl @@ -4,11 +4,14 @@ -export( [ all/0 , groups/0 + , init_per_group/2 + , end_per_group/2 ]). %% Test cases -export( - [ t_pipe/1 + [ t_pipe_ok/1 + , t_pipe_error/1 ]). @@ -24,20 +27,32 @@ all() -> groups() -> Tests = - [ t_pipe + [ t_pipe_ok + , t_pipe_error ], Properties = [], [{?GROUP_PIPE, Properties, Tests}]. - -%% ============================================================================= -%% Test cases -%% ============================================================================= - -t_pipe(_Config) -> +init_per_group(?GROUP_PIPE, Cfg) -> Steps = [ fun (0) -> {ok, 1}; (X) -> {error, X} end , fun (1) -> {ok, 2}; (X) -> {error, X} end , fun (2) -> {ok, 3}; (X) -> {error, X} end ], + hope_kv_list:set(Cfg, steps, Steps). + +end_per_group(?GROUP_PIPE, _Cfg) -> + ok. + + +%% ============================================================================= +%% Test cases +%% ============================================================================= + +t_pipe_ok(Cfg) -> + {some, Steps} = hope_kv_list:get(Cfg, steps), {ok, 3} = hope_result:pipe(Steps, 0). + +t_pipe_error(Cfg) -> + {some, Steps} = hope_kv_list:get(Cfg, steps), + {error, 1} = hope_result:pipe(Steps, 1).