clap/tests/yaml.rs

45 lines
1.3 KiB
Rust
Raw Normal View History

2018-01-25 04:05:05 +00:00
#![cfg(feature = "yaml")]
2016-01-12 05:13:14 +00:00
2020-02-03 18:04:07 +00:00
use clap::{load_yaml, App};
#[test]
fn create_app_from_yaml() {
2020-02-04 08:10:53 +00:00
let yml = load_yaml!("fixtures/app.yml");
2019-06-19 22:49:09 +00:00
App::from(yml);
2016-01-12 05:13:14 +00: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 08:10:53 +00:00
// let yml = load_yaml!("fixtures/app_2space.yml");
// App::from(yml);
// }
#[test]
fn help_message() {
2020-02-04 08:10:53 +00:00
let yml = load_yaml!("fixtures/app.yml");
2019-06-19 22:49:09 +00:00
let mut app = App::from(yml);
// Generate the full help message!
let _ = app.try_get_matches_from_mut(Vec::<String>::new());
let mut help_buffer = Vec::new();
app.write_help(&mut help_buffer).unwrap();
let help_string = String::from_utf8(help_buffer).unwrap();
2018-01-25 04:05:05 +00:00
assert!(
help_string.contains("-h, --help prints help with a nonstandard description\n")
);
}
#[test]
fn author() {
2020-02-04 08:10:53 +00:00
let yml = load_yaml!("fixtures/app.yml");
2019-06-19 22:49:09 +00:00
let mut app = App::from(yml);
// Generate the full help message!
let _ = app.try_get_matches_from_mut(Vec::<String>::new());
let mut help_buffer = Vec::new();
app.write_help(&mut help_buffer).unwrap();
let help_string = String::from_utf8(help_buffer).unwrap();
2018-01-25 04:05:05 +00:00
assert!(help_string.contains("Kevin K. <kbknapp@gmail.com>"));
}