Skip to content

Commit

Permalink
Upgrade test_path_with_offset to create temporary directory + files f…
Browse files Browse the repository at this point in the history
…or testing rather than pointing to existing dir.
  • Loading branch information
corwinjoy committed Jan 27, 2025
1 parent e58e10f commit 4e3a697
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions object_store/src/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1434,24 +1434,30 @@ mod tests {

#[tokio::test]
async fn test_path_with_offset() {
let root_str = "../testing/data/arrow-ipc-file";
let root = PathBuf::from(root_str);

let integration = LocalFileSystem::new_with_prefix(root).unwrap();
let root = TempDir::new().unwrap();
let integration = LocalFileSystem::new_with_prefix(root.path()).unwrap();

let filter_str = "clusterfuzz-testcase-minimized-arrow-ipc-file-fuzz-";
let root_path = root.path();
for i in 0..5 {
let filename = format!("test{}.parquet", i);
let file = root_path.join(filename);
std::fs::write(file, "test").unwrap();
}
let filter_str = "test";
let filter = String::from(filter_str);
let offset_str = filter + "6298268401401856";
let offset_str = filter + "1";
let offset = Path::from(offset_str.clone());

// Use list_with_offset to retrieve files
let res = integration.list_with_offset(None, &offset);
let offset_paths: Vec<_> = res.map_ok(|x| x.location).try_collect().await.unwrap();
let offset_files: Vec<_> = offset_paths
let mut offset_files: Vec<_> = offset_paths
.iter()
.map(|x| String::from(x.filename().unwrap()))
.collect();

let files = fs::read_dir(root_str).unwrap();
// Check result with direct filesystem read
let files = fs::read_dir(root_path).unwrap();
let filtered_files = files
.filter_map(Result::ok)
.filter_map(|d| {
Expand All @@ -1465,7 +1471,7 @@ mod tests {
})
.collect::<Vec<_>>();

let expected_offset_files: Vec<_> = filtered_files
let mut expected_offset_files: Vec<_> = filtered_files
.iter()
.filter(|s| **s > offset_str)
.cloned()
Expand All @@ -1476,6 +1482,9 @@ mod tests {
matching == a.len() && matching == b.len()
}

offset_files.sort();
expected_offset_files.sort();

// println!("Expected Offset Files: {:?}", expected_offset_files);
// println!("Actual Offset Files: {:?}", offset_files);

Expand Down

0 comments on commit 4e3a697

Please sign in to comment.