From 08d426b1850d0d1598e46a1edf0df6c689a77e97 Mon Sep 17 00:00:00 2001 From: David Souther Date: Mon, 6 Nov 2023 12:23:11 -0500 Subject: [PATCH] Rust: Remove 'make_page' testing helper (#5607) * Remove 'make_page' helper --- .../examples/testing/src/enums.rs | 8 +++--- .../examples/testing/src/traits.rs | 8 +++--- .../examples/testing/src/wrapper.rs | 27 ++++++++++--------- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/rust_dev_preview/examples/testing/src/enums.rs b/rust_dev_preview/examples/testing/src/enums.rs index 59077acc673..75279478c32 100644 --- a/rust_dev_preview/examples/testing/src/enums.rs +++ b/rust_dev_preview/examples/testing/src/enums.rs @@ -148,10 +148,10 @@ mod test { let fake = ListObjects::Test { expected_bucket: "test-bucket".into(), expected_prefix: "test-prefix".into(), - pages: vec![[5, 2i64] - .iter() - .map(|size| Object::builder().size(*size).build()) - .collect()], + pages: vec![vec![ + Object::builder().size(5).build(), + Object::builder().size(2).build(), + ]], }; // Run the code we want to test with it diff --git a/rust_dev_preview/examples/testing/src/traits.rs b/rust_dev_preview/examples/testing/src/traits.rs index f9a5f53bbed..5358423bc23 100644 --- a/rust_dev_preview/examples/testing/src/traits.rs +++ b/rust_dev_preview/examples/testing/src/traits.rs @@ -146,10 +146,10 @@ mod test { let fake = TestListObjects { expected_bucket: "test-bucket".into(), expected_prefix: "test-prefix".into(), - pages: vec![[5, 2i64] - .iter() - .map(|size| Object::builder().size(*size).build()) - .collect()], + pages: vec![vec![ + Object::builder().size(5).build(), + Object::builder().size(2).build(), + ]], }; // Run the code we want to test with it diff --git a/rust_dev_preview/examples/testing/src/wrapper.rs b/rust_dev_preview/examples/testing/src/wrapper.rs index a842e3be5fe..bfba83a212f 100644 --- a/rust_dev_preview/examples/testing/src/wrapper.rs +++ b/rust_dev_preview/examples/testing/src/wrapper.rs @@ -74,15 +74,6 @@ pub async fn determine_prefix_file_size( } // snippet-end:[testing.rust.wrapper] -#[allow(dead_code)] -// This time, we add a helper function for making pages -fn make_page(sizes: &[i64]) -> Vec { - sizes - .iter() - .map(|size| s3::types::Object::builder().size(*size).build()) - .collect() -} - #[cfg(test)] mod test { use super::*; @@ -96,7 +87,11 @@ mod test { .with(eq("test-bucket"), eq("test-prefix"), eq(None)) .return_once(|_, _, _| { Ok(ListObjectsV2Output::builder() - .set_contents(Some(make_page(&[5, 2]))) + .set_contents(Some(vec![ + // Mock content for ListObjectsV2 response + s3::types::Object::builder().size(5).build(), + s3::types::Object::builder().size(2).build(), + ])) .build()) }); @@ -117,7 +112,11 @@ mod test { .with(eq("test-bucket"), eq("test-prefix"), eq(None)) .return_once(|_, _, _| { Ok(ListObjectsV2Output::builder() - .set_contents(Some(make_page(&[5, 2]))) + .set_contents(Some(vec![ + // Mock content for ListObjectsV2 response + s3::types::Object::builder().size(5).build(), + s3::types::Object::builder().size(2).build(), + ])) .set_next_continuation_token(Some("next".to_string())) .build()) }); @@ -129,7 +128,11 @@ mod test { ) .return_once(|_, _, _| { Ok(ListObjectsV2Output::builder() - .set_contents(Some(make_page(&[3, 9]))) + .set_contents(Some(vec![ + // Mock content for ListObjectsV2 response + s3::types::Object::builder().size(3).build(), + s3::types::Object::builder().size(9).build(), + ])) .build()) });