diff --git a/crates/env/src/tests.rs b/crates/env/src/tests.rs index 93f9cba..0e70ff5 100644 --- a/crates/env/src/tests.rs +++ b/crates/env/src/tests.rs @@ -30,7 +30,11 @@ use crate::env; // ---------------------------------------------------------------- #[cfg(test)] -mod env_tests; +#[cfg(unix)] +mod env_unix_tests; +#[cfg(test)] +#[cfg(windows)] +mod env_windows_test; // ---------------------------------------------------------------- diff --git a/crates/env/src/tests/env_unix_tests.rs b/crates/env/src/tests/env_unix_tests.rs new file mode 100644 index 0000000..b087229 --- /dev/null +++ b/crates/env/src/tests/env_unix_tests.rs @@ -0,0 +1,80 @@ +/* + * Copyright © 2024 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// tests/env_unix_tests + +#![allow(unused_imports)] + +// @formatter:off +// ---------------------------------------------------------------- + +#[rustfmt::skip] +mod imports { + pub use omigacore::collection::table::{Table, Value}; + +pub use crate::env::Environment; +pub use crate::env::standard::StandardEnvironment; +pub use crate::reader::registry::ConfigReaderRegistry; +pub use crate::reader::toml::TomlConfigReader; + +} + +// @formatter:on +// ---------------------------------------------------------------- + +#[test] +#[cfg(unix)] +fn test_standard_environment_builder_os_unix() { + let rvt = StandardEnvironment::builder() + .with_table(Table::new()) + .with_registry(Box::new(ConfigReaderRegistry::default())) + .with_reader(Box::new(TomlConfigReader::default())) + .with_path("./testdata".to_string()) + .with_paths(vec!["./configs".to_string()]) + .with_config("omiga".to_string()) + .with_configs(vec!["application".to_string()]) + .with_profile("dev".to_string()) + .with_profiles(vec!["test".to_string()]) + .with_format("toml".to_string()) + .with_formats(vec!["toml".to_string()]) + .with_formats(vec!["toml".to_string(), "toml".to_string()]) + .with_search_path("/opt/app/configs".to_string()) + .with_search_paths(vec!["/data/configs".to_string()]) + .build(); + + assert!(rvt.is_ok()); +} + +// ---------------------------------------------------------------- + +#[test] +#[cfg(unix)] +fn test_standard_environment_os_unix() { + let rvt = StandardEnvironment::builder() + .with_table(Table::new()) + .with_registry(Box::new(ConfigReaderRegistry::default())) + .with_reader(Box::new(TomlConfigReader::default())) + .with_path("./testdata".to_string()) + .with_config("omiga".to_string()) + .with_profile("dev".to_string()) + .with_format("toml".to_string()) + .with_search_path("/opt/app/configs".to_string()) + .build(); + + let environment = rvt.unwrap(); + + assert!(environment.get("JAVA_HOME").is_ok()); +} diff --git a/crates/env/src/tests/env_tests.rs b/crates/env/src/tests/env_windows_test.rs similarity index 66% rename from crates/env/src/tests/env_tests.rs rename to crates/env/src/tests/env_windows_test.rs index e5d9c55..8fa4592 100644 --- a/crates/env/src/tests/env_tests.rs +++ b/crates/env/src/tests/env_windows_test.rs @@ -14,16 +14,23 @@ * limitations under the License. */ -// tests/env_tests +// tests/env_windows_test + +#![allow(unused_imports)] // ---------------------------------------------------------------- -use omigacore::collection::table::{Table, Value}; +use imports::*; + +#[rustfmt::skip] +mod imports { + pub use omigacore::collection::table::{Table, Value}; -use crate::env::standard::StandardEnvironment; -use crate::env::Environment; -use crate::reader::registry::ConfigReaderRegistry; -use crate::reader::toml::TomlConfigReader; + pub use crate::env::Environment; + pub use crate::env::standard::StandardEnvironment; + pub use crate::reader::registry::ConfigReaderRegistry; + pub use crate::reader::toml::TomlConfigReader; +} // ---------------------------------------------------------------- @@ -50,29 +57,6 @@ fn test_standard_environment_builder_os_windows() { assert!(rvt.is_ok()); } -#[test] -#[cfg(unix)] -fn test_standard_environment_builder_os_unix() { - let rvt = StandardEnvironment::builder() - .with_table(Table::new()) - .with_registry(Box::new(ConfigReaderRegistry::default())) - .with_reader(Box::new(TomlConfigReader::default())) - .with_path("./testdata".to_string()) - .with_paths(vec!["./configs".to_string()]) - .with_config("omiga".to_string()) - .with_configs(vec!["application".to_string()]) - .with_profile("dev".to_string()) - .with_profiles(vec!["test".to_string()]) - .with_format("toml".to_string()) - .with_formats(vec!["toml".to_string()]) - .with_formats(vec!["toml".to_string(), "toml".to_string()]) - .with_search_path("/opt/app/configs".to_string()) - .with_search_paths(vec!["/data/configs".to_string()]) - .build(); - - assert!(rvt.is_ok()); -} - // ---------------------------------------------------------------- #[test] @@ -100,25 +84,6 @@ fn test_standard_environment_os_windows() { ); } -#[test] -#[cfg(unix)] -fn test_standard_environment_os_unix() { - let rvt = StandardEnvironment::builder() - .with_table(Table::new()) - .with_registry(Box::new(ConfigReaderRegistry::default())) - .with_reader(Box::new(TomlConfigReader::default())) - .with_path("./testdata".to_string()) - .with_config("omiga".to_string()) - .with_profile("dev".to_string()) - .with_format("toml".to_string()) - .with_search_path("/opt/app/configs".to_string()) - .build(); - - let environment = rvt.unwrap(); - - assert!(environment.get("JAVA_HOME").is_ok()); -} - #[test] #[cfg(windows)] fn test_standard_environment_os_unix() {