From 55b9e52337d6164404cc467e7d827a34c9b80fda Mon Sep 17 00:00:00 2001 From: shivaraj-bh Date: Mon, 2 Dec 2024 14:18:41 +0530 Subject: [PATCH] config: Fix missing sub-config test --- crates/omnix-common/src/config.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/crates/omnix-common/src/config.rs b/crates/omnix-common/src/config.rs index 3a2ba42a..5daef327 100644 --- a/crates/omnix-common/src/config.rs +++ b/crates/omnix-common/src/config.rs @@ -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::("health").unwrap(); + let (res_empty_reference, _rest) = om_config_empty_reference + .get_sub_config_under::("health") + .unwrap(); + let (res_with_reference, _rest) = om_config_with_reference + .get_sub_config_under::("health") + .unwrap(); - assert_eq!(res, String::default()); + assert_eq!(res_empty_reference, String::default()); + assert_eq!(res_with_reference, String::default()); } #[tokio::test]