From 23ad253e1977db8cbb049a00063a93a9057f237b Mon Sep 17 00:00:00 2001 From: overtrue Date: Tue, 5 May 2026 13:08:15 +0800 Subject: [PATCH] test(s3): cover list versions NotFound fallback --- crates/s3/src/client.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/crates/s3/src/client.rs b/crates/s3/src/client.rs index d79e8ea..7f5fbbe 100644 --- a/crates/s3/src/client.rs +++ b/crates/s3/src/client.rs @@ -3656,6 +3656,32 @@ mod tests { } } + #[tokio::test] + async fn list_object_versions_page_maps_not_found_code_to_not_found() { + let response = http::Response::builder() + .status(404) + .header("x-amz-error-code", "NotFound") + .body(SdkBody::from( + r#" + + NotFound + The specified bucket does not exist. +"#, + )) + .expect("build not found bucket response"); + let (client, _request_receiver) = test_s3_client(Some(response)); + let path = RemotePath::new("test", "missing-bucket", ""); + + let result = client.list_object_versions_page(&path, Some(1000)).await; + + match result { + Err(Error::NotFound(message)) => { + assert_eq!(message, "Bucket not found: missing-bucket") + } + other => panic!("Expected NotFound for NotFound list versions error, got: {other:?}"), + } + } + #[tokio::test] async fn delete_bucket_maps_bucket_not_empty_to_conflict() { let response = http::Response::builder()