Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: move some unit tests to e2e #3218

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions e2e/cli/test_bin_paths
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

mise use dummy@latest
assert "mise bin-paths" "$MISE_DATA_DIR/installs/dummy/2.0.0/bin"
15 changes: 0 additions & 15 deletions src/cli/bin_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,3 @@ impl BinPaths {
Ok(())
}
}

#[cfg(test)]
mod tests {
use crate::test::reset;

#[test]
fn test_bin_paths() {
reset();
assert_cli!("i");
assert_cli_snapshot!("bin-paths", @r"
~/data/installs/tiny/3.1.0/bin
~/data/installs/dummy/ref-master/bin
");
}
}
73 changes: 0 additions & 73 deletions src/cli/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,76 +81,3 @@ static AFTER_LONG_HELP: &str = color_print::cstr!(
$ <bold>execx($(mise env -s xonsh))</bold>
"#
);

#[cfg(test)]
mod tests {
use std::env;

use pretty_assertions::assert_str_eq;
use test_log::test;

use crate::cli::tests::grep;
use crate::dirs;
use crate::test::reset;

#[test]
fn test_env() {
reset();
let stdout = assert_cli!("env", "-s", "bash");
assert!(stdout.contains(
dirs::DATA
.join("installs/tiny/3.1.0/bin")
.to_string_lossy()
.as_ref()
));
}

#[test]
fn test_env_with_runtime_arg() {
reset();
assert_cli!("install", "tiny@3.0");
let stdout = assert_cli!("env", "tiny@3.0", "-s", "bash");

assert!(stdout.contains(
dirs::DATA
.join("installs/tiny/3.0.1/bin")
.to_string_lossy()
.as_ref()
));
}

#[test]
fn test_env_alias() {
reset();
assert_cli!("plugin", "add", "tiny");
assert_cli!("install", "tiny@my/alias");
let stdout = assert_cli!("env", "tiny@my/alias", "-s", "bash");
assert!(stdout.contains(
dirs::DATA
.join("installs/tiny/3.0.1")
.to_string_lossy()
.as_ref()
));
}

#[test]
fn test_env_tiny() {
reset();
let stdout = assert_cli!("env", "tiny@2", "tiny@1", "tiny@3", "-s", "bash");
assert_str_eq!(grep(stdout, "JDXCODE"), "export JDXCODE_TINY=2.1.0");
}

#[test]
fn test_env_default_shell() {
reset();
env::set_var("SHELL", "");
let stdout = assert_cli!("env");
assert!(stdout.contains("export PATH="));
}

#[test]
fn test_env_json() {
reset();
assert_cli_snapshot!("env", "-J");
}
}
24 changes: 0 additions & 24 deletions src/cli/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,27 +214,3 @@ static AFTER_LONG_HELP: &str = color_print::cstr!(
$ <bold>mise upgrade --interactive</bold>
"#
);

#[cfg(test)]
pub mod tests {
use crate::dirs;
use crate::test::{change_installed_version, reset};

#[test]
fn test_upgrade() {
reset();
change_installed_version("tiny", "3.1.0", "3.0.0");
assert_cli_snapshot!("upgrade", "--dry-run");
assert_cli_snapshot!("upgrade");
assert!(dirs::INSTALLS.join("tiny").join("3.1.0").exists());
}

#[test]
fn test_upgrade_bump() {
reset();
change_installed_version("tiny", "3.1.0", "3.0.0");
assert_cli_snapshot!("upgrade", "--dry-run", "--bump");
assert_cli_snapshot!("upgrade");
assert!(dirs::INSTALLS.join("tiny").join("3.1.0").exists());
}
}