Assert error message for Windows besides *nix

The 'Tests on windows-latest' now failed with error message below

---- option::test::test_meilli_config_file_path_invalid stdout ----
thread 'option::test::test_meilli_config_file_path_invalid' panicked at 'assertion failed:
  left: `"unable to open or read the \"../configgg.toml\" configuration file: The system cannot find the file specified. (os error 2)."`,
 right: `"unable to open or read the \"../configgg.toml\" configuration file: No such file or directory (os error 2)."`', meilisearch-http\src\option.rs:555:17

https://github.com/meilisearch/meilisearch/actions/runs/3231941308/jobs/5291998750
This commit is contained in:
Lawrence Chou 2022-10-14 14:49:31 +08:00
parent 9ebc73e6ac
commit 53e5229b4a
No known key found for this signature in database
GPG Key ID: 56B65EC9D482438D

View File

@ -529,6 +529,7 @@ fn default_log_level() -> String {
#[cfg(test)]
mod test {
use super::*;
#[test]
@ -551,9 +552,16 @@ mod test {
temp_env::with_vars(
vec![("MEILI_CONFIG_FILE_PATH", Some("../configgg.toml"))],
|| {
assert_eq!(
Opt::try_build().unwrap_err().to_string(),
"unable to open or read the \"../configgg.toml\" configuration file: No such file or directory (os error 2)."
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
);
},
);