Skip to content

c.Param called in handler test returns empty string #2393

Answered by DGuhr
DGuhr asked this question in Q&A
Discussion options

You must be logged in to vote

ok, thanks to this StackOverflow answer it seems I figured it out:

after initializing the context inside the test, you have to define the path, the pathparam and the actual value, too, so the test code for me looks now like:

  echoCtx := e.NewContext(req, rec)
  echoCtx.SetPath("/tenant/:tenant/user")
  echoCtx.SetParamNames("tenant")
  echoCtx.SetParamValues("customer1")

Would be nice to know if this is really the idiomatic way.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@aldas
Comment options

aldas Feb 4, 2023
Maintainer

Answer selected by DGuhr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants