Gin: May I create a mock context?

Created on 6 Apr 2018  路  1Comment  路  Source: gin-gonic/gin

Hi, I'm trying to test json binding and maybe I'm looking at this from the wrong angle, but I can't find the way to achieve what I want.
I would like to write some unit tests around json binding, Ideally I'd like to have a method with a json string as input and a struct as output, where I can check that the string was successfully parsed.

I want a mock context because I want to peek inside the struct, in that case, using httptest makes no sense for me because I don't want to put the marshaled struct in the response.

I hope that my intention is clear, feel free to ask for any clarification needed.

Thanks.

Most helpful comment

>All comments

Was this page helpful?
0 / 5 - 0 ratings

Related issues

CodingPapi picture CodingPapi  路  3Comments

ghost picture ghost  路  3Comments

mastrolinux picture mastrolinux  路  3Comments

olegsobchuk picture olegsobchuk  路  3Comments

boneq picture boneq  路  3Comments