mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-12-25 06:00:08 +01:00
Merge #5174
5174: Split tests for option crate meilisearch in a separate test file r=irevoire a=K-Kumar-01 # Pull Request Splits the tests for meilisearch option crate in a separate testfile. ## Related issue Partially solves #5116 ## What does this PR do? - Splits the test for `/src/option.rs` into a separate file `/src/option_test.rs` in meilisearch crate ## PR checklist Please check if your PR fulfills the following requirements: - [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)? - [x] Have you read the contributing guidelines? - [x] Have you made sure that the title is accurate and descriptive of the changes? Co-authored-by: Kushal Kumar <kushalkumargupta4@gmail.com>
This commit is contained in:
commit
6987cac1ba
@ -7,6 +7,8 @@ pub mod extractors;
|
|||||||
pub mod metrics;
|
pub mod metrics;
|
||||||
pub mod middleware;
|
pub mod middleware;
|
||||||
pub mod option;
|
pub mod option;
|
||||||
|
#[cfg(test)]
|
||||||
|
mod option_test;
|
||||||
pub mod routes;
|
pub mod routes;
|
||||||
pub mod search;
|
pub mod search;
|
||||||
pub mod search_queue;
|
pub mod search_queue;
|
||||||
|
@ -1018,43 +1018,3 @@ where
|
|||||||
}
|
}
|
||||||
deserializer.deserialize_any(BoolOrInt)
|
deserializer.deserialize_any(BoolOrInt)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod test {
|
|
||||||
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_valid_opt() {
|
|
||||||
assert!(Opt::try_parse_from(Some("")).is_ok());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
#[ignore]
|
|
||||||
fn test_meilli_config_file_path_valid() {
|
|
||||||
temp_env::with_vars(
|
|
||||||
vec![("MEILI_CONFIG_FILE_PATH", Some("../config.toml"))], // Relative path in meilisearch package
|
|
||||||
|| {
|
|
||||||
assert!(Opt::try_build().is_ok());
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
#[ignore]
|
|
||||||
fn test_meilli_config_file_path_invalid() {
|
|
||||||
temp_env::with_vars(vec![("MEILI_CONFIG_FILE_PATH", Some("../configgg.toml"))], || {
|
|
||||||
let possible_error_messages = [
|
|
||||||
"unable to open or read the \"../configgg.toml\" configuration file: No such file or directory (os error 2).",
|
|
||||||
"unable to open or read the \"../configgg.toml\" configuration file: The system cannot find the file specified. (os error 2).", // Windows
|
|
||||||
];
|
|
||||||
let error_message = Opt::try_build().unwrap_err().to_string();
|
|
||||||
assert!(
|
|
||||||
possible_error_messages.contains(&error_message.as_str()),
|
|
||||||
"Expected onf of {:?}, got {:?}.",
|
|
||||||
possible_error_messages,
|
|
||||||
error_message
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
36
crates/meilisearch/src/option_test.rs
Normal file
36
crates/meilisearch/src/option_test.rs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
use crate::option::Opt;
|
||||||
|
use clap::Parser;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_valid_opt() {
|
||||||
|
assert!(Opt::try_parse_from(Some("")).is_ok());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[ignore]
|
||||||
|
fn test_meilli_config_file_path_valid() {
|
||||||
|
temp_env::with_vars(
|
||||||
|
vec![("MEILI_CONFIG_FILE_PATH", Some("../config.toml"))], // Relative path in meilisearch package
|
||||||
|
|| {
|
||||||
|
assert!(Opt::try_build().is_ok());
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[ignore]
|
||||||
|
fn test_meilli_config_file_path_invalid() {
|
||||||
|
temp_env::with_vars(vec![("MEILI_CONFIG_FILE_PATH", Some("../configgg.toml"))], || {
|
||||||
|
let possible_error_messages = [
|
||||||
|
"unable to open or read the \"../configgg.toml\" configuration file: No such file or directory (os error 2).",
|
||||||
|
"unable to open or read the \"../configgg.toml\" configuration file: The system cannot find the file specified. (os error 2).", // Windows
|
||||||
|
];
|
||||||
|
let error_message = Opt::try_build().unwrap_err().to_string();
|
||||||
|
assert!(
|
||||||
|
possible_error_messages.contains(&error_message.as_str()),
|
||||||
|
"Expected onf of {:?}, got {:?}.",
|
||||||
|
possible_error_messages,
|
||||||
|
error_message
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user