Skip to content

Commit

Permalink
add ut
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyFan2002 committed Sep 5, 2024
1 parent b95dfce commit da8f9ac
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions src/query/storages/common/table_meta/src/meta/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,41 @@ pub fn try_extract_uuid_str_from_path(path: &str) -> databend_common_exception::
)))
}
}

#[cfg(test)]
mod tests {
use databend_common_base::base::uuid::Uuid;

use super::*;

#[test]
fn test_trim_vacuum2_object_prefix() {
let uuid = Uuid::now_v7();
assert_eq!(
trim_vacuum2_object_prefix(&format!("g{}", uuid)),
uuid.to_string()
);
assert_eq!(
trim_vacuum2_object_prefix(&uuid.to_string()),
uuid.to_string()
);
}

#[test]
fn test_try_extract_uuid_str_from_path() {
let test_cases = vec![
(
"bucket/root/115/122/_b/g0191114d30fd78b89fae8e5c88327725_v2.parquet",
"0191114d30fd78b89fae8e5c88327725",
),
(
"bucket/root/115/122/_b/0191114d30fd78b89fae8e5c88327725_v2.parquet",
"0191114d30fd78b89fae8e5c88327725",
),
];

for (input, expected) in test_cases {
assert_eq!(try_extract_uuid_str_from_path(input).unwrap(), expected);
}
}
}

0 comments on commit da8f9ac

Please sign in to comment.