Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What type of PR is this? (check all applicable)
Description
Hello!
This pr adds some tests for checking that MethodNotAllowed error is returned correctly in some cases. All new tests are passing in current
main
branch state. But some of them are not passing inv1.8.1
(b4617d0).In released version
404
can be returned instead of405
when after adding required route, another one with different method and url was added. And also there is a difference in how the route was created. It is also important to make a request to required path withMethod
used in the second route. Sending request with every new and different method that was added after required route with required method will return404
instead of405
. Sending requests with method that hasn't been previously added will work fine and return405
. Example:This test is passing in both versions. But next example is not passing in
v1.18.1
:The only change here is that
HandleFunc().Methods()
is replaced withMethods().Path().Handler()
. So different way of creation of router leads to an error. The difference inv1.18.1
in produced routes was in order of matchers in inner array. Thats want I've mentioned. Wasn't able to identify how this influenced the result. Also I found different ways of how routes can be produced with this error:Currently provided tests do not cover cases of route possible varying way of creation except
HandleFunc
. So i added them, trying to check all possible ways of adding routes.Despite issue being fixed new tests can ensure that it wont return later.
If I've missed something, let me know please.
Related Tickets & Documents
Added/updated tests?
have not been included
Run verifications and test
make verify
is passingmake test
is passing