Skip to content

Commit

Permalink
add ut
Browse files Browse the repository at this point in the history
  • Loading branch information
xushiyan committed Jan 22, 2025
1 parent 570071d commit 4efe8a0
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion crates/core/src/config/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -126,6 +129,13 @@ mod tests {
InputPartitions.parse_value(&options).unwrap().to::<usize>(),
100
);
assert_eq!(
ListingParallelism
.parse_value(&options)
.unwrap()
.to::<usize>(),
100
);
assert!(UseReadOptimizedMode
.parse_value(&options)
.unwrap()
Expand All @@ -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!(
Expand All @@ -148,6 +159,16 @@ mod tests {
.to::<usize>(),
0
);
assert!(matches!(
ListingParallelism.parse_value(&options).unwrap_err(),
ParseInt(_, _, _)
));
assert_eq!(
ListingParallelism
.parse_value_or_default(&options)
.to::<usize>(),
10
);
assert!(matches!(
UseReadOptimizedMode.parse_value(&options).unwrap_err(),
ParseBool(_, _, _)
Expand Down

0 comments on commit 4efe8a0

Please sign in to comment.