Skip to content

Add HTTP::Convert tests and fix Curl.pm dead code#69

Draft
toddr-bot wants to merge 2 commits intomainfrom
koan.toddr.bot/test-http-convert
Draft

Add HTTP::Convert tests and fix Curl.pm dead code#69
toddr-bot wants to merge 2 commits intomainfrom
koan.toddr.bot/test-http-convert

Conversation

@toddr-bot
Copy link
Copy Markdown
Contributor

@toddr-bot toddr-bot commented Apr 6, 2026

What

Add 38 direct tests for Net::ACME2::HTTP::Convert and fix a dead code / bare die issue in Curl.pm.

Why

HTTP::Convert is the shared error-routing layer between both HTTP backends (HTTP_Tiny and Curl) but had zero direct test coverage. This module decides whether a response becomes a success object, a network exception, or a protocol exception -- getting this wrong silently breaks both backends.

The _assign_headers function in Curl.pm had a tautological condition (die ... if ref $value inside an elsif (ref $value) block) and used a bare string die instead of a structured exception.

How

  • Test file exercises all three code paths in http_tiny_to_net_acme2(): success (200/201/204/301/399), network error (599 with various content), and protocol error (400/403/404/500).
  • Verifies exception properties (method, url, status, reason, headers, redirects, error content).
  • Tests the 399/400 boundary to confirm the >= 400 threshold.
  • Curl.pm fix: removed tautological guard, replaced bare die with X::Generic that reports the ref type and header name.

Testing

All 345 tests pass across 21 files (including the 38 new ones).


Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com


Quality Report

Changes: 3 files changed, 345 insertions(+), 1 deletion(-)

Code scan: clean

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

toddr-bot and others added 2 commits April 6, 2026 06:13
HTTP::Convert is the shared error-routing layer between both HTTP
backends (HTTP_Tiny and Curl) but had zero direct test coverage.
38 tests covering: success responses (200/201/204), redirects (301),
network errors (599 with connection refused, TLS failures, redirects),
protocol errors (400/403/404/500 with headers/redirects), and the
399/400 boundary condition.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The elsif branch on line 239 already guarantees ref($value) is true,
making the inner `die ... if ref $value` tautological. Also replaced
the bare string die with a structured X::Generic exception that
reports the actual ref type and header name for debuggability.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant