2018-01-24 23:05:05 -05:00
|
|
|
#![cfg(feature = "yaml")]
|
2021-11-18 14:27:21 -06:00
|
|
|
#![allow(deprecated)]
|
2016-01-11 21:13:14 -08:00
|
|
|
|
2022-02-11 21:48:29 -06:00
|
|
|
use clap::{load_yaml, Command};
|
2015-08-30 23:26:17 -04:00
|
|
|
|
|
|
|
#[test]
|
2022-02-14 15:47:20 -06:00
|
|
|
fn create_cmd_from_yaml() {
|
2021-12-02 15:28:04 -06:00
|
|
|
let yml = load_yaml!("app.yml");
|
2022-02-11 21:48:29 -06:00
|
|
|
Command::from_yaml(yml);
|
2016-01-11 21:13:14 -08:00
|
|
|
}
|
2017-03-10 01:52:02 -05:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn help_message() {
|
2021-12-02 15:28:04 -06:00
|
|
|
let yml = load_yaml!("app.yml");
|
2022-02-14 15:47:20 -06:00
|
|
|
let mut cmd = Command::from_yaml(yml);
|
2017-03-10 01:52:02 -05:00
|
|
|
// Generate the full help message!
|
2022-02-14 15:47:20 -06:00
|
|
|
let _ = cmd.get_matches_from_safe_borrow(Vec::<String>::new());
|
2017-03-10 01:52:02 -05:00
|
|
|
|
|
|
|
let mut help_buffer = Vec::new();
|
2022-02-14 15:47:20 -06:00
|
|
|
cmd.write_help(&mut help_buffer).unwrap();
|
2017-03-10 01:52:02 -05:00
|
|
|
let help_string = String::from_utf8(help_buffer).unwrap();
|
2021-12-02 15:28:04 -06:00
|
|
|
println!("{}", &help_string);
|
|
|
|
assert!(help_string.contains("tests positionals with exclusions\n"));
|
2017-03-10 01:52:02 -05:00
|
|
|
}
|
2017-03-22 13:19:23 +05:30
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn author() {
|
2021-12-02 15:28:04 -06:00
|
|
|
let yml = load_yaml!("app.yml");
|
2022-02-14 15:47:20 -06:00
|
|
|
let mut cmd = Command::from_yaml(yml);
|
2017-03-22 13:19:23 +05:30
|
|
|
// Generate the full help message!
|
2022-02-14 15:47:20 -06:00
|
|
|
let _ = cmd.get_matches_from_safe_borrow(Vec::<String>::new());
|
2017-03-22 13:19:23 +05:30
|
|
|
|
|
|
|
let mut help_buffer = Vec::new();
|
2022-02-14 15:47:20 -06:00
|
|
|
cmd.write_help(&mut help_buffer).unwrap();
|
2017-03-22 13:19:23 +05:30
|
|
|
let help_string = String::from_utf8(help_buffer).unwrap();
|
2021-12-02 15:28:04 -06:00
|
|
|
println!("{}", &help_string);
|
2018-01-24 23:05:05 -05:00
|
|
|
assert!(help_string.contains("Kevin K. <kbknapp@gmail.com>"));
|
2017-03-22 13:19:23 +05:30
|
|
|
}
|