Skip to content

Commit

Permalink
feat: Update: 1.remove imports mod;2.add hold-on ut.
Browse files Browse the repository at this point in the history
Signed-off-by: photowey <[email protected]>
  • Loading branch information
photowey committed Jul 18, 2024
1 parent cc3adb2 commit 94bac19
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 24 deletions.
40 changes: 27 additions & 13 deletions crates/env/src/tests/env_unix_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,39 @@

#![allow(unused_imports)]

// @formatter:off
// ----------------------------------------------------------------

#[rustfmt::skip]
use imports::*;
use omigacore::collection::table::{Table, Value};

#[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;
}

// @formatter:on
// ----------------------------------------------------------------

#[test]
fn test_hold_on_imports() {
let rvt = StandardEnvironment::builder()
.with_table(Table::new())
.with_registry(Box::new(ConfigReaderRegistry::default()))
.with_reader(Box::new(TomlConfigReader::default()))
.with_config("omiga".to_string())
.with_profile("dev".to_string())
.with_format("toml".to_string())
.build();

let mut environment = rvt.unwrap();
environment
.set("io.github.photowey", Value::String("omiga".to_string()))
.expect("Set failed");

assert_eq!(
environment.get("io.github.photowey"),
Ok(&Value::String("omiga".to_string()))
);
}

#[test]
#[cfg(unix)]
fn test_standard_environment_builder_os_unix() {
Expand Down
38 changes: 27 additions & 11 deletions crates/env/src/tests/env_windows_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,37 @@

// ----------------------------------------------------------------

#[rustfmt::skip]
use imports::*;
use omigacore::collection::table::{Table, Value};

#[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;
}
use crate::env::standard::StandardEnvironment;
use crate::env::Environment;
use crate::reader::registry::ConfigReaderRegistry;
use crate::reader::toml::TomlConfigReader;

// ----------------------------------------------------------------

#[test]
fn test_hold_on_imports() {
let rvt = StandardEnvironment::builder()
.with_table(Table::new())
.with_registry(Box::new(ConfigReaderRegistry::default()))
.with_reader(Box::new(TomlConfigReader::default()))
.with_config("omiga".to_string())
.with_profile("dev".to_string())
.with_format("toml".to_string())
.build();

let mut environment = rvt.unwrap();
environment
.set("io.github.photowey", Value::String("omiga".to_string()))
.expect("Set failed");

assert_eq!(
environment.get("io.github.photowey"),
Ok(&Value::String("omiga".to_string()))
);
}

#[test]
#[cfg(windows)]
fn test_standard_environment_builder_os_windows() {
Expand Down

0 comments on commit 94bac19

Please sign in to comment.