From 4efe8a002c6c1f6f87a185667318ce9d709e65fd Mon Sep 17 00:00:00 2001 From: Shiyan Xu <2701446+xushiyan@users.noreply.github.com> Date: Tue, 21 Jan 2025 22:37:36 -0600 Subject: [PATCH] add ut --- crates/core/src/config/read.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/crates/core/src/config/read.rs b/crates/core/src/config/read.rs index ee97ee4..97d8a0f 100644 --- a/crates/core/src/config/read.rs +++ b/crates/core/src/config/read.rs @@ -111,12 +111,15 @@ impl ConfigParser for HudiReadConfig { #[cfg(test)] mod tests { use super::*; - use crate::config::read::HudiReadConfig::{InputPartitions, UseReadOptimizedMode}; + use crate::config::read::HudiReadConfig::{ + InputPartitions, ListingParallelism, UseReadOptimizedMode, + }; #[test] fn parse_valid_config_value() { let options = HashMap::from([ (InputPartitions.as_ref().to_string(), "100".to_string()), + (ListingParallelism.as_ref().to_string(), "100".to_string()), ( UseReadOptimizedMode.as_ref().to_string(), "true".to_string(), @@ -126,6 +129,13 @@ mod tests { InputPartitions.parse_value(&options).unwrap().to::(), 100 ); + assert_eq!( + ListingParallelism + .parse_value(&options) + .unwrap() + .to::(), + 100 + ); assert!(UseReadOptimizedMode .parse_value(&options) .unwrap() @@ -136,6 +146,7 @@ mod tests { fn parse_invalid_config_value() { let options = HashMap::from([ (InputPartitions.as_ref().to_string(), "foo".to_string()), + (ListingParallelism.as_ref().to_string(), "_100".to_string()), (UseReadOptimizedMode.as_ref().to_string(), "1".to_string()), ]); assert!(matches!( @@ -148,6 +159,16 @@ mod tests { .to::(), 0 ); + assert!(matches!( + ListingParallelism.parse_value(&options).unwrap_err(), + ParseInt(_, _, _) + )); + assert_eq!( + ListingParallelism + .parse_value_or_default(&options) + .to::(), + 10 + ); assert!(matches!( UseReadOptimizedMode.parse_value(&options).unwrap_err(), ParseBool(_, _, _)