Skip to content

test(s3s): improve unit test coverage for core HTTP and DTO modules#528

Merged
Nugine merged 3 commits intomainfrom
test/coverage
Mar 1, 2026
Merged

test(s3s): improve unit test coverage for core HTTP and DTO modules#528
Nugine merged 3 commits intomainfrom
test/coverage

Conversation

@Nugine
Copy link
Member

@Nugine Nugine commented Mar 1, 2026

Summary

Adds unit tests for 7 previously under-tested modules in the s3s crate, significantly raising line and branch coverage across the HTTP serialization/deserialization layer and core DTO types.

Coverage Gains

Module Lines Before Lines After Branches Before Branches After
http/etag.rs 0% 100% 0% 100%
dto/streaming_blob.rs 0% 95% 0% 89%
dto/range.rs 84% 98% 73% 96%
dto/timestamp.rs 68% 98% 60% 100%
http/body.rs 41% 90% 63% 97%
http/de.rs 14% 92% 17% 88%
http/ser.rs 22% 83% 36% 89%

All 7 modules now exceed 80% line coverage. Three reach ≥97%.

Tests Added

http/etag.rs

  • ETag / ETagConditionTryFromHeaderValue / TryIntoHeaderValue round-trips
  • Strong, weak, and unquoted ETag header parsing and encoding

dto/streaming_blob.rs

  • StreamingBlob::new and async polling
  • StreamingBlob::wrap with custom error type mapping
  • Debug formatting, remaining_length, ByteStream trait
  • From<Body> / Into<DynByteStream> conversions; empty stream edge case

dto/timestamp.rs

  • EpochSeconds: integer, negative, all fractional digit lengths (1–9), overflow
  • SystemTimeTimestamp conversion
  • serde serialize/deserialize round-trip; invalid input for all three formats
  • Ord and Hash trait behavior

http/body.rs

  • Body variants: Empty, Once, BoxBody, UnsyncBoxBody — is_end_stream, size_hint, poll_frame
  • Stream and ByteStream trait impls; bytes(), take_bytes()
  • Debug output for all Kind variants; BodySizeLimitExceeded display
  • store_all_limited: success, exceeded limit, empty body

http/de.rs

  • TryFromHeaderValue for bool, i32, i64, String
  • parse_header / parse_opt_header: present, missing, empty, duplicate
  • parse_opt_header_timestamp: present, missing, invalid
  • parse_query / parse_opt_query: present, missing, duplicate, invalid, no query string
  • unwrap_bucket / unwrap_object: success and panic paths
  • take_string_body: valid UTF-8, empty, invalid UTF-8
  • take_xml_body / take_opt_xml_body: empty body handling
  • parse_opt_metadata: none, some, empty key ignored, duplicate header
  • parse_list_header / parse_opt_list_header: single, multiple, missing
  • parse_field_value / parse_field_value_timestamp: found, not found, invalid
  • ParseHeaderError display

http/ser.rs

  • TryIntoHeaderValue for bool, i32, i64, String
  • add_opt_header: Some, None, bool
  • add_opt_header_timestamp: Some, None
  • set_stream_body; add_opt_metadata: Some, None, empty map

dto/range.rs

  • to_header_string for all three variants; round-trip with parse
  • TryFromHeaderValue for Range
  • RangeNotSatisfiableS3Error conversion
  • Edge cases: first / last exceeding i64::MAX, first > last

Notes

Remaining gaps (set_xml_body, Hyper body variant, parse_checksum_algorithm_header) require either XML-serializable types, hyper::body::Incoming infrastructure, or generated enum setup — better suited for integration/E2E tests.

Copilot AI review requested due to automatic review settings March 1, 2026 16:11
@codecov
Copy link

codecov bot commented Mar 1, 2026

Codecov Report

❌ Patch coverage is 99.33628% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/s3s/src/http/body.rs 97.83% 1 Missing and 3 partials ⚠️
crates/s3s/src/dto/streaming_blob.rs 96.87% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@Nugine Nugine added this pull request to the merge queue Mar 1, 2026
Merged via the queue into main with commit 2fa67f4 Mar 1, 2026
18 checks passed
@Nugine Nugine deleted the test/coverage branch March 1, 2026 16:58
@Nugine Nugine mentioned this pull request Mar 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants