Skip to content

feat: add celeristest.WithHandlers for middleware chain testing#140

Merged
FumingPower3925 merged 1 commit intomainfrom
feat/celeristest-with-handlers
Mar 31, 2026
Merged

feat: add celeristest.WithHandlers for middleware chain testing#140
FumingPower3925 merged 1 commit intomainfrom
feat/celeristest-with-handlers

Conversation

@FumingPower3925
Copy link
Copy Markdown
Contributor

Summary

  • Add celeristest.WithHandlers(...HandlerFunc) option to set a handler chain on test contexts
  • Add ctxkit.SetHandlers internal hook to bridge the type boundary
  • Register SetHandlers in context.go init block

This enables the goceleris/middlewares v0.1.0 testutil.RunChain helper, which tests nested middleware (e.g. recovery wrapping a panicking handler, logger timing downstream).

Closes #139

Changes

File Change
internal/ctxkit/ctxkit.go Add SetHandlers func(c any, handlers []any) hook
context.go Register hook: converts []any[]HandlerFunc, sets on context
celeristest/celeristest.go Add handlers []any to config, WithHandlers option, apply in NewContext

Test plan

  • go test ./celeristest/... passes
  • go build ./... passes
  • Verified via goceleris/middlewares testutil.RunChain — all 9 packages pass with -race

@FumingPower3925 FumingPower3925 added this to the v1.2.1 milestone Mar 31, 2026
@FumingPower3925 FumingPower3925 self-assigned this Mar 31, 2026
@FumingPower3925 FumingPower3925 merged commit f107268 into main Mar 31, 2026
10 checks passed
@FumingPower3925 FumingPower3925 deleted the feat/celeristest-with-handlers branch March 31, 2026 16:33
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.

celeristest: add WithHandlers option for middleware chain testing

1 participant