Skip to content

Commit

Permalink
Rust: Remove 'make_page' testing helper (awsdocs#5607)
Browse files Browse the repository at this point in the history
* Remove 'make_page' helper
  • Loading branch information
DavidSouther authored and meyertst-aws committed Jan 4, 2024
1 parent 521fedb commit 8d9282b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
8 changes: 4 additions & 4 deletions rust_dev_preview/examples/testing/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions rust_dev_preview/examples/testing/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 15 additions & 12 deletions rust_dev_preview/examples/testing/src/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<s3::types::Object> {
sizes
.iter()
.map(|size| s3::types::Object::builder().size(*size).build())
.collect()
}

#[cfg(test)]
mod test {
use super::*;
Expand All @@ -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())
});

Expand All @@ -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())
});
Expand All @@ -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())
});

Expand Down

0 comments on commit 8d9282b

Please sign in to comment.