Commit | Line | Data |
---|---|---|
7e9d7f2c SK |
1 | -module(hope_result_SUITE). |
2 | ||
3 | %% Callbacks | |
4 | -export( | |
5 | [ all/0 | |
6 | , groups/0 | |
126c8880 SK |
7 | , init_per_group/2 |
8 | , end_per_group/2 | |
7e9d7f2c SK |
9 | ]). |
10 | ||
11 | %% Test cases | |
12 | -export( | |
126c8880 SK |
13 | [ t_pipe_ok/1 |
14 | , t_pipe_error/1 | |
7e9d7f2c SK |
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 = | |
126c8880 SK |
30 | [ t_pipe_ok |
31 | , t_pipe_error | |
7e9d7f2c SK |
32 | ], |
33 | Properties = [], | |
34 | [{?GROUP_PIPE, Properties, Tests}]. | |
35 | ||
126c8880 | 36 | init_per_group(?GROUP_PIPE, Cfg) -> |
7e9d7f2c | 37 | Steps = |
55182c1b SK |
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 | |
7e9d7f2c | 41 | ], |
126c8880 SK |
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), | |
55182c1b | 54 | {ok, 3} = hope_result:pipe(Steps, 0). |
126c8880 SK |
55 | |
56 | t_pipe_error(Cfg) -> | |
57 | {some, Steps} = hope_kv_list:get(Cfg, steps), | |
58 | {error, 1} = hope_result:pipe(Steps, 1). |