aboutsummaryrefslogtreecommitdiffstats
path: root/tests/cli.rs
diff options
context:
space:
mode:
authorSven-Hendrik Haase <svenstaro@gmail.com>2021-03-28 19:07:22 +0000
committerGitHub <noreply@github.com>2021-03-28 19:07:22 +0000
commitdbb01e65af551342bce1d3f4664b2c37a46b3f08 (patch)
treef9ce11b4602c5c97fc6c8e9d940e321fa2fa90f9 /tests/cli.rs
parent(cargo-release) start next development iteration 0.12.2-alpha.0 (diff)
parentGenerate completions with `miniserve --print-completions <shell>` (diff)
downloadminiserve-dbb01e65af551342bce1d3f4664b2c37a46b3f08.tar.gz
miniserve-dbb01e65af551342bce1d3f4664b2c37a46b3f08.zip
Merge pull request #482 from rouge8/shell-completions
Generate completions with `miniserve --print-completions <shell>`
Diffstat (limited to 'tests/cli.rs')
-rw-r--r--tests/cli.rs28
1 files changed, 27 insertions, 1 deletions
diff --git a/tests/cli.rs b/tests/cli.rs
index e09473d..f88b284 100644
--- a/tests/cli.rs
+++ b/tests/cli.rs
@@ -3,7 +3,7 @@ mod fixtures;
use assert_cmd::prelude::*;
use fixtures::Error;
use std::process::Command;
-use structopt::clap::{crate_name, crate_version};
+use structopt::clap::{crate_name, crate_version, Shell};
#[test]
/// Show help and exit.
@@ -27,3 +27,29 @@ fn version_shows() -> Result<(), Error> {
Ok(())
}
+
+#[test]
+/// Print completions and exit.
+fn print_completions() -> Result<(), Error> {
+ for shell in &Shell::variants() {
+ Command::cargo_bin("miniserve")?
+ .arg("--print-completions")
+ .arg(&shell)
+ .assert()
+ .success();
+ }
+
+ Ok(())
+}
+
+#[test]
+/// Print completions rejects invalid shells.
+fn print_completions_invalid_shell() -> Result<(), Error> {
+ Command::cargo_bin("miniserve")?
+ .arg("--print-completions")
+ .arg("fakeshell")
+ .assert()
+ .failure();
+
+ Ok(())
+}