• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #![cfg(feature = "env")]
2 
3 use crate::utils;
4 
5 use clap::Parser;
6 
7 #[test]
it_works()8 fn it_works() {
9     #[derive(Debug, PartialEq, Parser)]
10     #[command(rename_all_env = "kebab")]
11     struct BehaviorModel {
12         #[arg(env)]
13         be_nice: String,
14     }
15 
16     let help = utils::get_help::<BehaviorModel>();
17     assert!(help.contains("[env: be-nice=]"));
18 }
19 
20 #[test]
default_is_screaming()21 fn default_is_screaming() {
22     #[derive(Debug, PartialEq, Parser)]
23     struct BehaviorModel {
24         #[arg(env)]
25         be_nice: String,
26     }
27 
28     let help = utils::get_help::<BehaviorModel>();
29     assert!(help.contains("[env: BE_NICE=]"));
30 }
31 
32 #[test]
overridable()33 fn overridable() {
34     #[derive(Debug, PartialEq, Parser)]
35     #[command(rename_all_env = "kebab")]
36     struct BehaviorModel {
37         #[arg(env)]
38         be_nice: String,
39 
40         #[arg(rename_all_env = "pascal", env)]
41         be_aggressive: String,
42     }
43 
44     let help = utils::get_help::<BehaviorModel>();
45     assert!(help.contains("[env: be-nice=]"));
46     assert!(help.contains("[env: BeAggressive=]"));
47 }
48