#![cfg(not(windows))]
use crate::common::{TestRepo, add_standard_env_redactions, repo, wt_command};
use insta::Settings;
use insta_cmd::assert_cmd_snapshot;
use rstest::rstest;
fn snapshot_init(test_name: &str, repo: &TestRepo, shell: &str, extra_args: &[&str]) {
let mut settings = Settings::clone_current();
settings.set_snapshot_path("../snapshots");
add_standard_env_redactions(&mut settings);
settings.bind(|| {
let mut cmd = wt_command();
repo.configure_wt_cmd(&mut cmd);
cmd.arg("config").arg("shell").arg("init").arg(shell);
for arg in extra_args {
cmd.arg(arg);
}
cmd.current_dir(repo.root_path());
assert_cmd_snapshot!(test_name, cmd);
});
}
#[rstest]
#[case("bash")]
#[case("fish")]
#[case("zsh")]
fn test_init(#[case] shell: &str, repo: TestRepo) {
snapshot_init(&format!("init_{}", shell), &repo, shell, &[]);
}
#[rstest]
fn test_init_invalid_shell(repo: TestRepo) {
let mut settings = Settings::clone_current();
settings.set_snapshot_path("../snapshots");
add_standard_env_redactions(&mut settings);
settings.bind(|| {
let mut cmd = wt_command();
repo.configure_wt_cmd(&mut cmd);
cmd.arg("config")
.arg("shell")
.arg("init")
.arg("invalid-shell")
.current_dir(repo.root_path());
assert_cmd_snapshot!(cmd, @"
success: false
exit_code: 2
----- stdout -----
----- stderr -----
[1m[31merror:[0m invalid value '[1m[33minvalid-shell[0m' for '[1m[36m<bash|fish|nu|zsh|powershell>[0m'
[possible values: [1m[32mbash[0m, [1m[32mfish[0m, [1m[32mnu[0m, [1m[32mzsh[0m, [1m[32mpowershell[0m]
For more information, try '[1m[36m--help[0m'.
");
});
}