Skip to content

Commit

Permalink
Added tests for showing defaults in the installer.
Browse files Browse the repository at this point in the history
  • Loading branch information
londospark committed Dec 14, 2020
1 parent 714bc79 commit a78d470
Showing 1 changed file with 117 additions and 0 deletions.
117 changes: 117 additions & 0 deletions tests/cli-inst-interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,123 @@ Rust is installed now. Great!
});
}

#[test]
fn installer_shows_default_host_triple() {
clitools::setup(Scenario::SimpleV2, &|config| {
let out = run_input(config, &["rustup-init", "--no-modify-path"], "2\n");

println!("-- stdout --\n {}", out.stdout);
println!("-- stderr --\n {}", out.stderr);
assert!(out.stdout.contains(for_host!(
r"
Default host triple? [{0}]
"
)));
});
}

#[test]
fn installer_shows_default_toolchain_as_stable() {
clitools::setup(Scenario::SimpleV2, &|config| {
let out = run_input(config, &["rustup-init", "--no-modify-path"], "2\n\n");

println!("-- stdout --\n {}", out.stdout);
println!("-- stderr --\n {}", out.stderr);
assert!(out.stdout.contains(
r"
Default toolchain? (stable/beta/nightly/none) [stable]
"
));
});
}

#[test]
fn installer_shows_default_toolchain_when_set_in_args() {
clitools::setup(Scenario::SimpleV2, &|config| {
let out = run_input(
config,
&[
"rustup-init",
"--no-modify-path",
"--default-toolchain=nightly",
],
"2\n\n",
);

println!("-- stdout --\n {}", out.stdout);
println!("-- stderr --\n {}", out.stderr);
assert!(out.stdout.contains(
r"
Default toolchain? (stable/beta/nightly/none) [nightly]
"
));
});
}

#[test]
fn installer_shows_default_profile() {
clitools::setup(Scenario::SimpleV2, &|config| {
let out = run_input(config, &["rustup-init", "--no-modify-path"], "2\n\n\n");

println!("-- stdout --\n {}", out.stdout);
println!("-- stderr --\n {}", out.stderr);
assert!(out.stdout.contains(
r"
Profile (which tools and data to install)? (minimal/default/complete) [default]
"
));
});
}

#[test]
fn installer_shows_default_profile_when_set_in_args() {
clitools::setup(Scenario::SimpleV2, &|config| {
let out = run_input(
config,
&["rustup-init", "--no-modify-path", "--profile=minimal"],
"2\n\n\n",
);

println!("-- stdout --\n {}", out.stdout);
println!("-- stderr --\n {}", out.stderr);
assert!(out.stdout.contains(
r"
Profile (which tools and data to install)? (minimal/default/complete) [minimal]
"
));
});
}

#[test]
fn installer_shows_default_for_modify_path() {
clitools::setup(Scenario::SimpleV2, &|config| {
let out = run_input(config, &["rustup-init"], "2\n\n\n\n");

println!("-- stdout --\n {}", out.stdout);
println!("-- stderr --\n {}", out.stderr);
assert!(out.stdout.contains(
r"
Modify PATH variable? (Y/n)
"
));
});
}

#[test]
fn installer_shows_default_for_modify_path_when_set_with_args() {
clitools::setup(Scenario::SimpleV2, &|config| {
let out = run_input(config, &["rustup-init", "--no-modify-path"], "2\n\n\n\n");

println!("-- stdout --\n {}", out.stdout);
println!("-- stderr --\n {}", out.stderr);
assert!(out.stdout.contains(
r"
Modify PATH variable? (y/N)
"
));
});
}

#[test]
fn user_says_nope() {
clitools::setup(Scenario::SimpleV2, &|config| {
Expand Down

0 comments on commit a78d470

Please sign in to comment.