Skip to content

Commit

Permalink
test: Added tests for shell completion script support
Browse files Browse the repository at this point in the history
  • Loading branch information
yodaldevoid committed Mar 30, 2019
1 parent 770bf77 commit eed1d01
Showing 1 changed file with 109 additions and 2 deletions.
111 changes: 109 additions & 2 deletions tests/cli-misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
pub mod mock;

use crate::mock::clitools::{
self, expect_err, expect_ok, expect_ok_ex, expect_stderr_ok, expect_stdout_ok, run,
set_current_dist_date, this_host_triple, Config, Scenario,
self, expect_err, expect_ok, expect_ok_eq, expect_ok_ex, expect_stderr_ok, expect_stdout_ok,
run, set_current_dist_date, this_host_triple, Config, Scenario,
};
use rustup::dist::errors::TOOLSTATE_MSG;
use rustup::utils::{raw, utils};
Expand Down Expand Up @@ -789,3 +789,110 @@ fn update_unavailable_rustc() {
expect_stdout_ok(config, &["rustc", "--version"], "hash-n-1");
});
}

#[test]
fn completion_rustup() {
setup(&|config| {
expect_ok(
config,
&[
"rustup",
"completions",
"bash",
"rustup",
],
);
});
}

#[test]
fn completion_cargo() {
setup(&|config| {
expect_ok(
config,
&[
"rustup",
"completions",
"bash",
"cargo",
],
);
});
}

#[test]
fn completion_default() {
setup(&|config| {
expect_ok_eq(
config,
&[
"rustup",
"completions",
"bash",
],
&[
"rustup",
"completions",
"bash",
"rustup",
],
);
});
}

#[test]
fn completion_bad_shell() {
setup(&|config| {
expect_err(
config,
&[
"rustup",
"completions",
"fake",
],
"error: 'fake' isn't a valid value for '<shell>'",
);
expect_err(
config,
&[
"rustup",
"completions",
"fake",
"cargo",
],
"error: 'fake' isn't a valid value for '<shell>'",
);
});
}

#[test]
fn completion_bad_tool() {
setup(&|config| {
expect_err(
config,
&[
"rustup",
"completions",
"bash",
"fake",
],
"error: 'fake' isn't a valid value for '<command>'",
);
});
}

#[test]
fn completion_cargo_unsupported_shell() {
setup(&|config| {
expect_err(
config,
&[
"rustup",
"completions",
"fish",
"cargo",
],
"error: cargo does not currently support completions for ",
);
});
}

0 comments on commit eed1d01

Please sign in to comment.