test(http2): expand branch coverage for http2_client.cpp#1054
Merged
Conversation
Adds tests/unit/http2_client_branch_test.cpp with 35 hermetic tests for src/protocols/http2/http2_client.cpp, complementing http2_client_test.cpp, http2_client_coverage_test.cpp, and http2_client_extended_coverage_test.cpp. Covers public-API surfaces that remained uncovered after #991: - http2_response::get_header case-insensitive matrix and duplicate behaviour - http2_response::get_body_string empty/ASCII/binary/8KiB byte preservation - http2_settings all-zero, all-UINT32_MAX, and enable_push toggle round-trips - Repeated header_table_size updates exercising HPACK dynamic-table apply - http2_stream default invariants, move construction, move assignment, and promise/future plumbing across moves with populated buffers and callbacks - set_timeout zero, large, and monotonic update sequences - connect() to unreachable IPv4/IPv6 ports and unresolvable DNS literals - Disconnected-state early-return paths for every request helper and post-failed-connect helper re-invocation - is_connected and disconnect idempotency, repeated construction, empty and long client_id, concurrent is_connected/set_timeout queries Frame-handler paths remain uncovered by hermetic tests; reaching the 70% line / 60% branch acceptance bar will require a mock TLS socket layer (tracked separately). Closes #1048
Contributor
Coverage Report
Coverage DetailsFull HTML report is available as a build artifact. |
This was referenced Apr 26, 2026
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.
Closes #1048
What
Summary
Adds
tests/unit/http2_client_branch_test.cppwith 35 hermetic unit tests forsrc/protocols/http2/http2_client.cpp, complementinghttp2_client_test.cpp(#974),http2_client_coverage_test.cppandhttp2_client_extended_coverage_test.cpp(both #991).Change Type
Affected Components
tests/unit/http2_client_branch_test.cpp(new, 35 tests)tests/CMakeLists.txt(registersnetwork_http2_client_branch_test)CHANGELOG.md,docs/CHANGELOG.md(Tests / Added entries)Why
Problem Solved
src/protocols/http2/http2_client.cppmeasured 18.8% line / 9.9% branch ondevelop @ 05c1b7bb(workflow run 24947193873). The earlier sub-issue #991 only covered happy paths, leaving response-helper and lifecycle surfaces uncovered. Issue #1048 (Part of #953) requires raising this file towardline >= 70%andbranch >= 60%.Honest scope statement
This PR closes the hermetic public-API surfaces that remained uncovered after #991. The 70% line / 60% branch acceptance bar cannot be reached by hermetic unit tests alone — every frame-handler in
http2_client.cpp(process_frame,handle_data_frame,handle_settings_frame,handle_goaway_frame,handle_rst_stream_frame,handle_window_update_frame,handle_ping_frame,handle_headers_frame) currently has 0 hits and requires a mock TLS socket layer to drive. That infrastructure work is out of scope for this PR and should be tracked as a separate follow-up sub-issue under #953.Related Issues
Where
tests/unit/http2_client_branch_test.cpptests/CMakeLists.txtnetwork_http2_client_branch_test)CHANGELOG.md,docs/CHANGELOG.mdSource under test (
src/protocols/http2/http2_client.cpp) is NOT modified.How
Coverage scope (35 tests)
http2_response::get_headercase-insensitive matrix (mixed/lower/upper, leading/trailing whitespace non-match, duplicate first-match)http2_response::get_body_stringempty / ASCII / binary (0x00, 0xff) / 8KiB body byte preservationhttp2_settingsall-zero round-trip, all-UINT32_MAXround-trip,enable_pushtoggle without perturbing other fields, repeatedheader_table_sizeupdates (0/256/4096/65536/1/1024) exercising HPACK encoder/decoder dynamic-table applyhttp2_streamdefault-construction invariants, move construction with populated request/response buffers andon_datacallback, move assignment replacing prior state, promise/future plumbing across movehttp2_client::set_timeoutzero, very large (int64_t::max() / 2), and monotonic update sequenceshttp2_client::connect()unreachable IPv4 loopback port, unreachable IPv6 loopback port, unresolvable DNS literal, repeated failed connects leaving clean stateget,post(string),post(vector<uint8_t>),put,del,start_stream,write_stream(end_stream=false|true),close_stream_writer,cancel_streamconnect()to verify the rollback pathis_connected()immediately after construction,disconnect()idempotency before any connect, repeated construction (16 instances), empty client_id, 512-char client_idis_connected()queries (8 threads x 200 iterations), concurrentset_timeout(4 threads x 100 iterations)All tests are hermetic — no network, no filesystem, no sleeps beyond the
100mslistener-warm-up reused fromhttp2_client_extended_coverage_test.cpp.Testing Done
The new test file follows the same
#include, namespace, and helper-class patterns as the existinghttp2_client_extended_coverage_test.cpp, which is already a green CI target — minimizing risk of compile / link surprises.Breaking Changes
None — test-only addition.
Rollback Plan
Revert this PR. No source modifications, no CMake target removed.
Acceptance Criteria status (Issue #1048)
src/protocols/http2/http2_client.cpprecorded as an issue comment — will post after CI completesdevelopafter merge — NOT achievable by hermetic tests alone; see honest scope statement abovedevelopafter merge — NOT achievable by hermetic tests alone; see honest scope statement aboveThis PR delivers the maximum incremental hermetic coverage for #1048 and surfaces the structural blocker (no mock TLS socket layer) explicitly so that #953's epic-level decision-making has the right information.