Skip to content

Commit

Permalink
config: Fix missing sub-config test
Browse files Browse the repository at this point in the history
  • Loading branch information
shivaraj-bh authored and srid committed Dec 2, 2024
1 parent 6fc4819 commit 6790aa2
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions crates/omnix-common/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,26 @@ pub enum OmConfigError {

#[tokio::test]
async fn test_get_missing_sub_config() {
let om_config = OmConfig {
let om_config_empty_reference = OmConfig {
flake_url: FlakeUrl::from_str(".").unwrap(),
reference: vec![],
config: serde_yaml::from_str("").unwrap(),
};
let om_config_with_reference = OmConfig {
flake_url: FlakeUrl::from_str(".").unwrap(),
reference: vec!["foo".to_string()],
config: serde_yaml::from_str("").unwrap(),
};

let (res, _rest) = om_config.get_sub_config_under::<String>("health").unwrap();
let (res_empty_reference, _rest) = om_config_empty_reference
.get_sub_config_under::<String>("health")
.unwrap();
let (res_with_reference, _rest) = om_config_with_reference
.get_sub_config_under::<String>("health")
.unwrap();

assert_eq!(res, String::default());
assert_eq!(res_empty_reference, String::default());
assert_eq!(res_with_reference, String::default());
}

#[tokio::test]
Expand Down

0 comments on commit 6790aa2

Please sign in to comment.