2018-01-24 23:05:05 -05:00
|
|
|
#![cfg(feature = "yaml")]
|
2016-01-11 21:13:14 -08:00
|
|
|
|
2020-02-03 13:04:07 -05:00
|
|
|
use clap::{load_yaml, App};
|
2015-08-30 23:26:17 -04:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn create_app_from_yaml() {
|
2020-02-04 09:10:53 +01:00
|
|
|
let yml = load_yaml!("fixtures/app.yml");
|
2019-06-19 15:49:09 -07:00
|
|
|
App::from(yml);
|
2016-01-11 21:13:14 -08:00
|
|
|
}
|
2017-03-10 01:52:02 -05:00
|
|
|
|
2018-06-22 13:50:44 +02:00
|
|
|
// TODO: Uncomment to test yaml with 2 spaces https://github.com/chyh1990/yaml-rust/issues/101
|
|
|
|
// #[test]
|
|
|
|
// fn create_app_from_yaml_2spaces() {
|
2020-02-04 09:10:53 +01:00
|
|
|
// let yml = load_yaml!("fixtures/app_2space.yml");
|
2018-06-22 13:50:44 +02:00
|
|
|
// App::from(yml);
|
|
|
|
// }
|
|
|
|
|
2017-03-10 01:52:02 -05:00
|
|
|
#[test]
|
|
|
|
fn help_message() {
|
2020-02-04 09:10:53 +01:00
|
|
|
let yml = load_yaml!("fixtures/app.yml");
|
2019-06-19 15:49:09 -07:00
|
|
|
let mut app = App::from(yml);
|
2017-03-10 01:52:02 -05:00
|
|
|
// Generate the full help message!
|
2018-10-19 16:42:13 -04:00
|
|
|
let _ = app.try_get_matches_from_mut(Vec::<String>::new());
|
2017-03-10 01:52:02 -05:00
|
|
|
|
|
|
|
let mut help_buffer = Vec::new();
|
|
|
|
app.write_help(&mut help_buffer).unwrap();
|
|
|
|
let help_string = String::from_utf8(help_buffer).unwrap();
|
2020-05-03 02:13:24 -04:00
|
|
|
assert!(help_string
|
|
|
|
.contains("-h, --help prints help with a nonstandard description\n"));
|
2017-03-10 01:52:02 -05:00
|
|
|
}
|
2017-03-22 13:19:23 +05:30
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn author() {
|
2020-02-04 09:10:53 +01:00
|
|
|
let yml = load_yaml!("fixtures/app.yml");
|
2019-06-19 15:49:09 -07:00
|
|
|
let mut app = App::from(yml);
|
2017-03-22 13:19:23 +05:30
|
|
|
// Generate the full help message!
|
2018-10-19 16:42:13 -04:00
|
|
|
let _ = app.try_get_matches_from_mut(Vec::<String>::new());
|
2017-03-22 13:19:23 +05:30
|
|
|
|
|
|
|
let mut help_buffer = Vec::new();
|
|
|
|
app.write_help(&mut help_buffer).unwrap();
|
|
|
|
let help_string = String::from_utf8(help_buffer).unwrap();
|
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
|
|
|
}
|