Skip to content

test: add unit tests for internal/httputil package#2800

Merged
lpcox merged 3 commits intomainfrom
test/httputil-unit-tests
Mar 29, 2026
Merged

test: add unit tests for internal/httputil package#2800
lpcox merged 3 commits intomainfrom
test/httputil-unit-tests

Conversation

@lpcox
Copy link
Copy Markdown
Collaborator

@lpcox lpcox commented Mar 29, 2026

Summary

Adds unit tests for the internal/httputil package, which previously had no test coverage.

Tests Added

10 test cases for WriteJSONResponse:

  • Content-Type header (application/json)
  • Status code propagation (200, 201, 400, 404, 500)
  • JSON encoding: structs, maps, slices, nested types
  • Edge cases: nil body, empty struct, special characters, unicode

Verification

make agent-finished

Adds comprehensive tests for WriteJSONResponse covering:
- Content-Type header setting
- Status code propagation (200, 201, 400, 404, 500)
- JSON encoding of structs, maps, slices, nested types
- Nil body, empty struct, special characters, unicode

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 29, 2026 18:17
Copy link
Copy Markdown
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 initial unit test coverage for internal/httputil.WriteJSONResponse, the shared helper used by HTTP-facing packages (e.g., server/proxy) to emit JSON responses.

Changes:

  • Introduces a new internal/httputil/httputil_test.go with subtests covering headers, status codes, and JSON encoding for multiple body shapes.
  • Adds edge-case assertions for nil/empty bodies and for payloads containing special characters and unicode.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/httputil/httputil_test.go Outdated
Comment thread internal/httputil/httputil_test.go Outdated
lpcox and others added 2 commits March 29, 2026 11:25
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@lpcox lpcox merged commit e17005a into main Mar 29, 2026
13 checks passed
@lpcox lpcox deleted the test/httputil-unit-tests branch March 29, 2026 18:28
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