-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Http Assertions does not allow the creation of a body #925
Comments
We feel that it's reasonable to want to be able to set the body in certain cases. If you'd like to help out, feel free to open a PR. |
Hi @mvdkleijn , I just made changes for the issue, tried to push to a new branch and got 403, do I need some permissions to make PR? |
This sounds like you're new or perhaps I'm misunderstanding? 😄 The way you create a PR is by forking the repository to your own copy, create a branch with your changes pushed to it and then use the Github UI to create the PR. Basically that will be a request for us to merge changes from your fork into our original copy. It sounds like you were trying to push to a branch in the main Testify repository which is indeed off limits to all but the maintainers. Hope that helps! |
Yeah first time trying to contribute to open source, thanks, it helps :) |
No worries, feel free to ask more if desired. The Github docs also provide a lot of information on how to do things. Once you have the PR in place, I'll take a look and see if anything needs adjustment and once satisfied all looks good, we can merge it. 👍 |
No worries, it was straight forward. #938 |
@mvdkleijn hi i need help. very much help. i just joined the Github community yesterday and i don't understand a single thing I've been reading here 😩 |
I'm not sure what exactly your question is that I could help with...? |
should this issue be closed? |
Not really, since the merged PR was reverted by @boyan-soubachov and aa such the issue is still valid. |
Hello @boyan-soubachov, |
@ossan-dev See #938. |
see the details in #938 (comment) |
Is an issue still relevant? cc @arjunmahishi |
@myusko Looks like the linked PR's comments are still not addressed.
Yes. The request raised in this issue is still not satisfied. Based on my understanding of reading the comments on this issue and the PR, it looks like the PR was raised with |
Any ideas on how this could be done without introducing breaking changes? I can't seem to find a solution that doesn't involve an extension of the surface of the library (the b scenario, in this comment) |
#1491 is related. What do the HTTP handler assertions offer over calling the handler with a httptest.ResponseRecorder? |
The only http assertions available right now are on the response status codes ( |
I mean, why are the HTTP assertions better than this: r := httptest.NewRequest(http.MethodGet, "http://example.com/biscuit", nil)
w := httptest.NewRecorder()
myHandler(w, r)
assert.Equal(t, http.StatusOK, w.Code)
assert.Equal(t, "custard cream", w.Body.String()) This only calls the handler once, so is a better test as it doesn't allow a stateful handler to sneak incorrect behaviour past the test. Like returning status code 500 with a correct body for every request after the first, for example. |
I agree that your example is much more effective. |
Maintain the existing ones. 🙂 |
Suggest to include this example in documentation and close this issue |
Since we're not accepting more assertions which call a handler I'm moving this to close. I've been thinking about where the above doc should live and I can't think of a good location in the package. Please do open a PR if you can think of one. Perhaps it would be better suited to a guide in the discussions section. Or possibly @Antonboom do you think testifylint should warn about use of the HTTP assertions and suggest it? |
Hi,
It seems like the HTTP Assert package does not allow me to specify a body to pass in a POST request for example. Looking at the
HTTPBody()
function, the body argument is set tonil
:req, err := http.NewRequest(method, url+"?"+values.Encode(), nil)
Is this by design, or am I looking at a missing feature?
Cheers,
The text was updated successfully, but these errors were encountered: