-
Notifications
You must be signed in to change notification settings - Fork 706
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to test Body() due to unexported variable body #721
Comments
BrunoKrugel
changed the title
Unable to teste Body() due to unexported variable body
Unable to test Body() due to unexported variable body
Oct 4, 2023
@BrunoKrugel Thanks for reaching out. I will add |
jeevatkm
added a commit
that referenced
this issue
Oct 8, 2023
jeevatkm
added a commit
that referenced
this issue
Oct 8, 2023
@BrunoKrugel Currently, it's available in |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In our tests, we use mockery, so we can mock the return value of our methods.
If I isolate my HTTP request in a method and return the
resty.Response
struct, I cannot mock thebody
value.In the following example, my
GetData()
method will call theSendPostRequest()
method that is mocked, with mockery I will set the value return from theSendPostRequest()
, that will be used afterwards inGetData()
.If I try to access the
Body
value from theresponse.Body()
it will return nill, bacause the method returns the value from theResponse
struct, which is private.All the other methods/values available in the Response struct, return the value from the
RawResponse
(for example theStatusCode
orStatus
), only the value ofbody
comes from a different source.Why the Body method check for
RawResponse
value if it will return the value ofbody
instead ofResponse.Body
?How can I set a custom
body
value directly in the Response structure instead of theRawResponse
? So I can get the value withBody()
.The text was updated successfully, but these errors were encountered: