Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DonJayamanne committed May 23, 2024
1 parent 63a1c13 commit a46dec8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
1 change: 1 addition & 0 deletions native_locator/tests/common_python_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ fn find_python_in_path_this() {
python_run_command: Some(vec![unix_python_exe.clone().to_str().unwrap().to_string()]),
env_path: Some(user_home.clone()),
arch: None,
..Default::default()
};
assert_messages(
&[json!(env)],
Expand Down
11 changes: 10 additions & 1 deletion native_locator/tests/conda_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ fn find_conda_exe_and_empty_envs() {
executable_path: conda_exe.clone(),
version: Some("4.0.2".to_string()),
tool: EnvManagerType::Conda,
company: None,
company_display_name: None,
};
assert_eq!(managers.len(), 1);
assert_eq!(json!(expected_conda_manager), json!(managers[0]));
Expand Down Expand Up @@ -177,12 +179,14 @@ fn find_conda_from_custom_install_location() {
executable_path: conda_exe.clone(),
version: Some("4.0.2".to_string()),
tool: EnvManagerType::Conda,
company: None,
company_display_name: None,
};
assert_eq!(json!(expected_conda_manager), json!(result.managers[0]));

let expected_conda_env = PythonEnvironment {
display_name: None,
name: Some("base".to_string()),
name: None,
project_path: None,
python_executable_path: Some(conda_dir.clone().join("bin").join("python")),
category: python_finder::messaging::PythonEnvironmentCategory::Conda,
Expand All @@ -197,6 +201,7 @@ fn find_conda_from_custom_install_location() {
"python".to_string(),
]),
arch: None,
..Default::default()
};
assert_eq!(json!(expected_conda_env), json!(result.environments[0]));

Expand Down Expand Up @@ -245,6 +250,8 @@ fn finds_two_conda_envs_from_known_location() {
executable_path: conda_exe.clone(),
version: Some("4.0.2".to_string()),
tool: EnvManagerType::Conda,
company: None,
company_display_name: None,
};

assert_eq!(managers.len(), 1);
Expand All @@ -267,6 +274,7 @@ fn finds_two_conda_envs_from_known_location() {
"python".to_string(),
]),
arch: None,
..Default::default()
};
let expected_conda_2 = PythonEnvironment {
display_name: None,
Expand All @@ -285,6 +293,7 @@ fn finds_two_conda_envs_from_known_location() {
"python".to_string(),
]),
arch: None,
..Default::default()
};
assert_messages(
&[json!(expected_conda_1), json!(expected_conda_2)],
Expand Down
25 changes: 18 additions & 7 deletions native_locator/tests/pyenv_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ fn does_not_find_any_pyenv_envs_even_with_pyenv_installed() {
use crate::common::{
assert_messages, create_test_environment, join_test_paths, test_file_path,
};
use python_finder::messaging::{EnvManager, EnvManagerType};
use python_finder::pyenv;
use python_finder::{conda::Conda, locator::Locator};
use serde_json::json;
Expand Down Expand Up @@ -57,14 +58,17 @@ fn does_not_find_any_pyenv_envs_even_with_pyenv_installed() {
let mut locator = pyenv::PyEnv::with(&known, &mut conda);
let result = locator.find().unwrap();

let managers = result.managers;
let managers = result.clone().managers;
assert_eq!(managers.len(), 1);

let expected_json = json!({"executablePath":pyenv_exe,"version":null, "tool": "pyenv"});
assert_messages(
&[expected_json],
&managers.iter().map(|e| json!(e)).collect::<Vec<_>>(),
)
let expected_manager = EnvManager {
executable_path: pyenv_exe.clone(),
version: None,
tool: EnvManagerType::Pyenv,
company: None,
company_display_name: None,
};
assert_eq!(json!(expected_manager), json!(result.managers[0]));
}

#[test]
Expand Down Expand Up @@ -103,6 +107,8 @@ fn find_pyenv_envs() {
executable_path: pyenv_exe.clone(),
version: None,
tool: EnvManagerType::Pyenv,
company: None,
company_display_name: None,
};
assert_eq!(json!(expected_manager), json!(result.managers[0]));

Expand All @@ -128,7 +134,8 @@ fn find_pyenv_envs() {
".pyenv/versions/3.9.9"
])),
env_manager: Some(expected_manager.clone()),
arch: None
arch: None,
..Default::default()
});
let expected_virtual_env = PythonEnvironment {
display_name: None,
Expand All @@ -153,6 +160,7 @@ fn find_pyenv_envs() {
])),
env_manager: Some(expected_manager.clone()),
arch: None,
..Default::default()
};
let expected_3_12_1 = PythonEnvironment {
display_name: None,
Expand All @@ -177,6 +185,7 @@ fn find_pyenv_envs() {
])),
env_manager: Some(expected_manager.clone()),
arch: None,
..Default::default()
};
let expected_3_13_dev = PythonEnvironment {
display_name: None,
Expand All @@ -201,6 +210,7 @@ fn find_pyenv_envs() {
])),
env_manager: Some(expected_manager.clone()),
arch: None,
..Default::default()
};
let expected_3_12_1a3 = PythonEnvironment {
display_name: None,
Expand All @@ -225,6 +235,7 @@ fn find_pyenv_envs() {
])),
env_manager: Some(expected_manager.clone()),
arch: None,
..Default::default()
};

assert_messages(
Expand Down

0 comments on commit a46dec8

Please sign in to comment.