test(s3s): improve unit test coverage for core HTTP and DTO modules#528
Merged
test(s3s): improve unit test coverage for core HTTP and DTO modules#528
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds targeted unit tests in the s3s crate to raise line/branch coverage across core HTTP (de/ser/body/etag) and DTO (timestamp/range/streaming_blob) modules, improving confidence in header/query parsing and body/stream behavior.
Changes:
- Introduces new test suites for
http::{etag, ser, de, body}covering header conversion, request parsing, and body streaming behaviors. - Adds DTO-focused tests for
dto::{timestamp, range, streaming_blob}covering parsing/formatting edge cases and stream conversions. - Expands existing test modules with additional edge-case assertions (e.g., Range parse limits, EpochSeconds fractional handling).
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/s3s/src/http/ser.rs | Adds unit tests for TryIntoHeaderValue, optional header setters, stream body setting, and metadata header emission. |
| crates/s3s/src/http/etag.rs | Adds ETag / ETagCondition header round-trip and parsing/encoding tests. |
| crates/s3s/src/http/de.rs | Adds broad unit test coverage for header/query parsing helpers, body extraction helpers, metadata parsing, and error display. |
| crates/s3s/src/http/body.rs | Adds tests for Body variants covering is_end_stream, size_hint, poll_frame, Stream/ByteStream behavior, Debug output, and size-limit errors. |
| crates/s3s/src/dto/timestamp.rs | Adds tests for EpochSeconds parsing edge cases, invalid inputs for all formats, conversions, serde round-trips, and Ord/Hash behavior. |
| crates/s3s/src/dto/streaming_blob.rs | Adds tests for StreamingBlob polling/wrapping, conversions, debug output, remaining length, and empty-stream behavior. |
| crates/s3s/src/dto/range.rs | Adds tests for header formatting, header parsing, error conversion, and parse edge cases around i64 bounds and invalid ranges. |
- Add assertion in add_opt_metadata_empty_map (ser.rs) - Add size_hint invariant assertion in streaming_blob_size_hint - Convert 3 async tests without await to sync #[test] (body.rs) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds unit tests for 7 previously under-tested modules in the
s3scrate, significantly raising line and branch coverage across the HTTP serialization/deserialization layer and core DTO types.Coverage Gains
http/etag.rsdto/streaming_blob.rsdto/range.rsdto/timestamp.rshttp/body.rshttp/de.rshttp/ser.rsAll 7 modules now exceed 80% line coverage. Three reach ≥97%.
Tests Added
http/etag.rsETag/ETagCondition↔TryFromHeaderValue/TryIntoHeaderValueround-tripsdto/streaming_blob.rsStreamingBlob::newand async pollingStreamingBlob::wrapwith custom error type mappingDebugformatting,remaining_length,ByteStreamtraitFrom<Body>/Into<DynByteStream>conversions; empty stream edge casedto/timestamp.rsEpochSeconds: integer, negative, all fractional digit lengths (1–9), overflowSystemTime→Timestampconversionserdeserialize/deserialize round-trip; invalid input for all three formatsOrdandHashtrait behaviorhttp/body.rsBodyvariants: Empty, Once, BoxBody, UnsyncBoxBody —is_end_stream,size_hint,poll_frameStreamandByteStreamtrait impls;bytes(),take_bytes()Debugoutput for allKindvariants;BodySizeLimitExceededdisplaystore_all_limited: success, exceeded limit, empty bodyhttp/de.rsTryFromHeaderValueforbool,i32,i64,Stringparse_header/parse_opt_header: present, missing, empty, duplicateparse_opt_header_timestamp: present, missing, invalidparse_query/parse_opt_query: present, missing, duplicate, invalid, no query stringunwrap_bucket/unwrap_object: success and panic pathstake_string_body: valid UTF-8, empty, invalid UTF-8take_xml_body/take_opt_xml_body: empty body handlingparse_opt_metadata: none, some, empty key ignored, duplicate headerparse_list_header/parse_opt_list_header: single, multiple, missingparse_field_value/parse_field_value_timestamp: found, not found, invalidParseHeaderErrordisplayhttp/ser.rsTryIntoHeaderValueforbool,i32,i64,Stringadd_opt_header: Some, None, booladd_opt_header_timestamp: Some, Noneset_stream_body;add_opt_metadata: Some, None, empty mapdto/range.rsto_header_stringfor all three variants; round-trip withparseTryFromHeaderValueforRangeRangeNotSatisfiable→S3Errorconversionfirst/lastexceedingi64::MAX,first > lastNotes
Remaining gaps (
set_xml_body,Hyperbody variant,parse_checksum_algorithm_header) require either XML-serializable types,hyper::body::Incominginfrastructure, or generated enum setup — better suited for integration/E2E tests.