Skip to main content

max / makenotwork

s3-storage: cover the streaming and buffered download forms too download_stream hands the caller an unread ByteStream, which is the one download shape the other tests do not exercise on the way past.
Co-Authored-By
Claude Opus 5 (1M context) <noreply@anthropic.com>
Author: Max Johnson <me@maxj.phd> · 2026-08-27 02:52 UTC
Signed with PGP, not checked
Commit: fdff741f2b0c197c3f6f06f09dff136856495b08
Parent: adb5ec3
1 file changed, +24 insertions, -0 deletions
@@ -183,6 +183,30 @@
183 183 cleanup(&s3, &key).await;
184 184 }
185 185
186 + #[tokio::test]
187 + #[ignore = "live S3"]
188 + async fn the_streaming_download_carries_the_same_bytes() {
189 + // `download` is `download_buf` plus a copy, and `download_buf` is the
190 + // aggregating form of this one, so the three share a path and only this one
191 + // hands the caller an unread stream.
192 + let s3 = client().await;
193 + let key = prefix("stream/a.bin");
194 + let body = pattern(200_000);
195 + s3.upload(&key, "application/octet-stream", body.clone(), None)
196 + .await
197 + .expect("upload");
198 +
199 + let stream = s3.download_stream(&key).await.expect("download_stream");
200 + let collected = stream.collect().await.expect("draining the stream");
201 + assert_same_bytes(&body, &collected.to_vec(), "streamed download");
202 +
203 + let (buffered, content_type) = s3.download_buf(&key).await.expect("download_buf");
204 + assert_same_bytes(&body, &buffered, "buffered download");
205 + assert_eq!(content_type, "application/octet-stream");
206 +
207 + cleanup(&s3, &key).await;
208 + }
209 +
186 210 #[tokio::test]
187 211 #[ignore = "live S3"]
188 212 async fn a_missing_object_is_absent_rather_than_an_error() {