test: cover Request.ignore-body? and Request.form-data#6
Conversation
There was a problem hiding this comment.
Build & Tests
- Lint (CI): Failing —
anglerreports 4nested-if-chainwarnings inhttp.carp(lines 285, 340, 440, 497). These are all in pre-existing code not touched by this PR (the PR only modifiestest/http.carp). The previous branch (claude/extract-header-lookup) passed CI on 2026-06-11, so the linter may have been updated since then. - Build (local): Fails due to pre-existing
const-correctness issue in thetimedependency's C codegen (TM.tm_zone), exactly as noted in the PR description. The test file itself is not the cause. - Type-check:
carp --check test/http.carppasses cleanly. - Tests: Cannot run locally due to the build failure above. The tests type-check and follow established patterns.
Findings
The tests themselves are correct and well-structured:
-
Request.ignore-body?tests (lines 282-292): cover HEAD (true), GET (false), POST (false). This fully exercises the function since it's simply(= (verb r) "HEAD"). -
Request.form-datatests (lines 298-330): cover key extraction, second key from multi-param body, percent-decoding (%20→ space), and empty body returning an empty map. Good coverage of the function's behavior. -
Constructor usage is correct —
Request.requestandRequest.post/Request.getare called with proper arguments matching the module's API.
No issues introduced by this PR. The CI failure and build failure are both pre-existing issues unrelated to the test additions.
Verdict: revise
The tests are correct, but CI is failing. The lint failures are pre-existing nested-if-chain warnings in http.carp — not caused by this PR. To get CI green, the existing nested-if-chain patterns in http.carp would need to be converted to cond expressions, but that's arguably a separate fix. If the maintainer is OK merging with pre-existing lint failures, the test code itself is sound.
|
lets fix the linter while were at it. |
Convert 4 nested if chains (Request.parse, Request.header, Response.parse, Response.header) to cond expressions.
|
Addressed @hellerve's request to fix the linter:
|
There was a problem hiding this comment.
Build & Tests
- CI: Passing (both macOS and Ubuntu) — lint, format, and test steps all green.
- Local build: Cannot compile locally (Carp not available on this ARM host), relying on CI results.
Prior feedback
- Previous review (carpentry-reviewer) flagged pre-existing
nested-if-chainlint warnings and recommended revise. hellerve asked to fix the linter. The agent converted all 4 nested-if-chain patterns tocondexpressions. This is now addressed — CI passes clean.
Findings
Tests (test/http.carp:282-329):
The 7 new assertions are well-structured:
Request.ignore-body?: covers HEAD (true), GET (false), POST (false). Since the implementation is(= (verb r) "HEAD")(http.carp:182), this fully exercises the function.Request.form-data: covers key extraction, second key from multi-param body, percent-decoding (%20→ space), and empty body returning empty map. Good coverage of the function, which delegates toForm.parse(http.carp:595).- Constructor usage is correct —
Request.request,Request.post, andRequest.getare called with proper arguments matching the module API.
Lint fix (http.carp:285, 339, 439, 495):
All four cond conversions are logically equivalent to the original nested if chains. I read each one in full context and the control flow is preserved:
- Request header parser (line 285): three-way branch on
eolvalue — correct. - Request.header lookup (line 339): two conditions + default — correct.
- Response header parser (line 439): same pattern as request parser — correct.
- Response.header lookup (line 495): same pattern as request — correct.
No issues found.
Verdict: merge
Tests are correct, lint fix is sound, CI is green. Good to merge.
Summary
Adds test coverage for two public functions that previously had none:
Request.ignore-body?— verifies it returnstruefor HEAD requests andfalsefor GET/POSTRequest.form-data— verifies key extraction, multiple parameters, percent-decoding, and empty body handlingThese 7 new assertions document the expected behaviour and guard against regressions.
Note: the existing test suite does not compile locally due to a pre-existing
const-correctness issue in thetimedependency's C codegen (TM.tm_zone). The new tests type-check cleanly (carp --check) and follow the same patterns as the existing test suite.Opened by the carpentry-org heartbeat agent (Claude). Veit has not reviewed this yet.