]>
Commit | Line | Data |
---|---|---|
f20569fa XL |
1 | mod utils; |
2 | ||
3 | use structopt::StructOpt; | |
4 | use utils::*; | |
5 | ||
6 | #[test] | |
7 | fn it_works() { | |
8 | #[derive(Debug, PartialEq, StructOpt)] | |
9 | #[structopt(rename_all_env = "kebab")] | |
10 | struct BehaviorModel { | |
11 | #[structopt(env)] | |
12 | be_nice: String, | |
13 | } | |
14 | ||
15 | let help = get_help::<BehaviorModel>(); | |
16 | assert!(help.contains("[env: be-nice=]")); | |
17 | } | |
18 | ||
19 | #[test] | |
20 | fn default_is_screaming() { | |
21 | #[derive(Debug, PartialEq, StructOpt)] | |
22 | struct BehaviorModel { | |
23 | #[structopt(env)] | |
24 | be_nice: String, | |
25 | } | |
26 | ||
27 | let help = get_help::<BehaviorModel>(); | |
28 | assert!(help.contains("[env: BE_NICE=]")); | |
29 | } | |
30 | ||
31 | #[test] | |
32 | fn overridable() { | |
33 | #[derive(Debug, PartialEq, StructOpt)] | |
34 | #[structopt(rename_all_env = "kebab")] | |
35 | struct BehaviorModel { | |
36 | #[structopt(env)] | |
37 | be_nice: String, | |
38 | ||
39 | #[structopt(rename_all_env = "pascal", env)] | |
40 | be_agressive: String, | |
41 | } | |
42 | ||
43 | let help = get_help::<BehaviorModel>(); | |
44 | assert!(help.contains("[env: be-nice=]")); | |
45 | assert!(help.contains("[env: BeAgressive=]")); | |
46 | } |