Skip to content

test: cover Request.ignore-body? and Request.form-data#6

Merged
hellerve merged 2 commits into
masterfrom
claude/test-form-data-ignore-body
Jun 13, 2026
Merged

test: cover Request.ignore-body? and Request.form-data#6
hellerve merged 2 commits into
masterfrom
claude/test-form-data-ignore-body

Conversation

@carpentry-agent

Copy link
Copy Markdown

Summary

Adds test coverage for two public functions that previously had none:

  • Request.ignore-body? — verifies it returns true for HEAD requests and false for GET/POST
  • Request.form-data — verifies key extraction, multiple parameters, percent-decoding, and empty body handling

These 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 the time dependency'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.

@carpentry-reviewer carpentry-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Build & Tests

  • Lint (CI): Failing — angler reports 4 nested-if-chain warnings in http.carp (lines 285, 340, 440, 497). These are all in pre-existing code not touched by this PR (the PR only modifies test/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 the time dependency'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.carp passes 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:

  1. 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").

  2. Request.form-data tests (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.

  3. Constructor usage is correct — Request.request and Request.post/Request.get are 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.

@hellerve

Copy link
Copy Markdown
Member

lets fix the linter while were at it.

Convert 4 nested if chains (Request.parse, Request.header, Response.parse,
Response.header) to cond expressions.
@carpentry-agent

Copy link
Copy Markdown
Author

Addressed @hellerve's request to fix the linter:

  • Converted all 4 nested-if-chain warnings flagged by @carpentry-reviewer (http.carp lines 285, 340, 440, 497) from nested if expressions to cond expressions.
  • Ran carp-fmt -w and angler — both pass clean now.

@carpentry-reviewer carpentry-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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-chain lint warnings and recommended revise. hellerve asked to fix the linter. The agent converted all 4 nested-if-chain patterns to cond expressions. 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 to Form.parse (http.carp:595).
  • Constructor usage is correct — Request.request, Request.post, and Request.get are 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:

  1. Request header parser (line 285): three-way branch on eol value — correct.
  2. Request.header lookup (line 339): two conditions + default — correct.
  3. Response header parser (line 439): same pattern as request parser — correct.
  4. 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.

@hellerve hellerve merged commit b9d0e4b into master Jun 13, 2026
2 checks passed
@hellerve hellerve deleted the claude/test-form-data-ignore-body branch June 13, 2026 21:39
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