-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: More exhaustively test current name/bin_name/display_name handl…
…ing behavior
- Loading branch information
1 parent
3208cda
commit ffff884
Showing
4 changed files
with
179 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
use clap::{Arg, Command}; | ||
use clap_markdown::{help_markdown_command_custom, MarkdownOptions}; | ||
|
||
use pretty_assertions::assert_eq; | ||
|
||
/// Test behavior for an app that defines a: | ||
/// | ||
/// * `name` | ||
/// * `display_name` | ||
/// | ||
/// but no custom `bin_name`. | ||
#[test] | ||
fn test_title_behavior_for_name_and_display_name_app() { | ||
let mut app = Command::new("my-program-name") | ||
// Note: Intentionally not setting custom bin name. | ||
// .bin_name("my-program-bin-name") | ||
.display_name("my-program-display-name") | ||
.version("1.2.3") | ||
.about("This program does things.") | ||
.arg(Arg::new("foo").short('f')); | ||
let () = app.build(); | ||
|
||
//------------------------------------------------------------------- | ||
// Test the native behavior of `clap`, in terms of whether it prefers | ||
// the `name`, `bin_name`, and `display_name` properties are used. | ||
//------------------------------------------------------------------- | ||
|
||
assert_eq!( | ||
app.render_long_help().to_string(), | ||
"\ | ||
This program does things. | ||
Usage: my-program-name [OPTIONS] | ||
Options: | ||
-f <foo> | ||
-h, --help | ||
Print help information | ||
-V, --version | ||
Print version information | ||
" | ||
); | ||
|
||
//------------------------------------------------------- | ||
// Test how clap-markdown handles the various name fields | ||
//------------------------------------------------------- | ||
|
||
assert_eq!( | ||
help_markdown_command_custom( | ||
&app, | ||
&MarkdownOptions::new().show_footer(false) | ||
), | ||
"\ | ||
# Command-Line Help for my-program-display-name | ||
This document contains the help content for the `my-program-name` command-line program. | ||
**Command Overview:** | ||
* [`my-program-name`↴](#my-program-name) | ||
## `my-program-name` | ||
This program does things. | ||
**Usage:** `my-program-name [OPTIONS]` | ||
###### **Options:** | ||
* `-f <FOO>` | ||
* `-h`, `--help` — Print help information | ||
* `-V`, `--version` — Print version information | ||
" | ||
); | ||
} | ||
|
||
/// Test behavior for an app that defines a: | ||
/// | ||
/// * `name` | ||
/// * `bin_name` | ||
/// * `display_name` | ||
#[test] | ||
fn test_title_behavior_for_name_bin_name_and_display_name_app() { | ||
let mut app = Command::new("my-program-name") | ||
.bin_name("my-program-bin-name") | ||
.display_name("my-program-display-name") | ||
.version("1.2.3") | ||
.about("This program does things.") | ||
.arg(Arg::new("foo").short('f')); | ||
let () = app.build(); | ||
|
||
//------------------------------------------------------------------- | ||
// Test the native behavior of `clap`, in terms of whether it prefers | ||
// the `name`, `bin_name`, and `display_name` properties are used. | ||
//------------------------------------------------------------------- | ||
|
||
assert_eq!( | ||
app.render_long_help().to_string(), | ||
"\ | ||
This program does things. | ||
Usage: my-program-bin-name [OPTIONS] | ||
Options: | ||
-f <foo> | ||
-h, --help | ||
Print help information | ||
-V, --version | ||
Print version information | ||
" | ||
); | ||
|
||
//------------------------------------------------------- | ||
// Test how clap-markdown handles the various name fields | ||
//------------------------------------------------------- | ||
|
||
assert_eq!( | ||
help_markdown_command_custom( | ||
&app, | ||
&MarkdownOptions::new().show_footer(false) | ||
), | ||
"\ | ||
# Command-Line Help for my-program-display-name | ||
This document contains the help content for the `my-program-name` command-line program. | ||
**Command Overview:** | ||
* [`my-program-name`↴](#my-program-name) | ||
## `my-program-name` | ||
This program does things. | ||
**Usage:** `my-program-bin-name [OPTIONS]` | ||
###### **Options:** | ||
* `-f <FOO>` | ||
* `-h`, `--help` — Print help information | ||
* `-V`, `--version` — Print version information | ||
" | ||
); | ||
} |