Skip to content

Refactor tests by httptest suite - #5

Merged
ghosind merged 1 commit into
go-amwk:mainfrom
ghosind:test/httptest-suite
Jul 21, 2026
Merged

Refactor tests by httptest suite#5
ghosind merged 1 commit into
go-amwk:mainfrom
ghosind:test/httptest-suite

Conversation

@ghosind

@ghosind ghosind commented Jul 21, 2026

Copy link
Copy Markdown
Member

No description provided.

Signed-off-by: Chen Su <ghosind@gmail.com>
@ghosind
ghosind requested a review from Copilot July 21, 2026 04:15
@ghosind ghosind added the enhancement New feature or request label Jul 21, 2026

Copilot AI 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.

Pull request overview

This PR refactors the engine’s test adapters to use Go’s net/http/httptest primitives, making request/response behavior in tests closer to real HTTP semantics.

Changes:

  • Reworked the test Request adapter to wrap *http.Request and derive fields (headers, cookies, URL, client IP) from it.
  • Reworked the test Response adapter to wrap an http.ResponseWriter (typically httptest.ResponseRecorder) and added a helper to flush buffered writes.
  • Updated context_test.go to build contexts from httptest.NewRequest / httptest.NewRecorder instead of manually mutating stub fields.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
engine_test.go Refactors test Request/Response adapters to delegate to *http.Request / http.ResponseWriter and adds a send() flush helper.
context_test.go Updates context tests to construct requests/responses via httptest and validate behavior using recorder output.

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

Comment thread engine_test.go
Comment on lines +100 to +101
func (r *Response) Status(code int) { r.code = code }
func (r *Response) StatusCode() int { return r.code }
@ghosind
ghosind merged commit f01cd62 into go-amwk:main Jul 21, 2026
9 checks passed
@ghosind
ghosind deleted the test/httptest-suite branch July 24, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants