| 1 | -module(hope_result_SUITE). |
| 2 | |
| 3 | %% Callbacks |
| 4 | -export( |
| 5 | [ all/0 |
| 6 | , groups/0 |
| 7 | , init_per_group/2 |
| 8 | , end_per_group/2 |
| 9 | ]). |
| 10 | |
| 11 | %% Test cases |
| 12 | -export( |
| 13 | [ t_pipe_ok/1 |
| 14 | , t_pipe_error/1 |
| 15 | ]). |
| 16 | |
| 17 | |
| 18 | -define(GROUP_PIPE, result_pipe). |
| 19 | |
| 20 | |
| 21 | %% ============================================================================ |
| 22 | %% Common Test callbacks |
| 23 | %% ============================================================================ |
| 24 | |
| 25 | all() -> |
| 26 | [{group, ?GROUP_PIPE}]. |
| 27 | |
| 28 | groups() -> |
| 29 | Tests = |
| 30 | [ t_pipe_ok |
| 31 | , t_pipe_error |
| 32 | ], |
| 33 | Properties = [], |
| 34 | [{?GROUP_PIPE, Properties, Tests}]. |
| 35 | |
| 36 | init_per_group(?GROUP_PIPE, Cfg) -> |
| 37 | Steps = |
| 38 | [ fun (0) -> {ok, 1}; (X) -> {error, X} end |
| 39 | , fun (1) -> {ok, 2}; (X) -> {error, X} end |
| 40 | , fun (2) -> {ok, 3}; (X) -> {error, X} end |
| 41 | ], |
| 42 | hope_kv_list:set(Cfg, steps, Steps). |
| 43 | |
| 44 | end_per_group(?GROUP_PIPE, _Cfg) -> |
| 45 | ok. |
| 46 | |
| 47 | |
| 48 | %% ============================================================================= |
| 49 | %% Test cases |
| 50 | %% ============================================================================= |
| 51 | |
| 52 | t_pipe_ok(Cfg) -> |
| 53 | {some, Steps} = hope_kv_list:get(Cfg, steps), |
| 54 | {ok, 3} = hope_result:pipe(Steps, 0). |
| 55 | |
| 56 | t_pipe_error(Cfg) -> |
| 57 | {some, Steps} = hope_kv_list:get(Cfg, steps), |
| 58 | {error, 1} = hope_result:pipe(Steps, 1). |