Closed dominicbarnes closed 3 months ago
Thank you for catching this and submitting a patch! It would be good to add a test, as well, which would fail prior to the patch, but pass after. Is that something you'd like to add?
@flimzy yeah, let me throw something together
@flimzy I just pushed bb18c2a6216ab298554db5c4b8867e77b51e05d1 which adds a test that fails before the change and passes after.
To avoid altering any other tests, this creates a new test helper which creates a client which inspects req.URL.RawPath
as part of the HTTP mock, returning an error if there is a mismatch.
This probably isn't the most elegant approach, but it certainly gets the job done short of pulling in a full HTTP mocking library. Let me know what you think, I'm happy to iterate on it further if you have any suggestions.
@flimzy after looking over some other tests, I found some other examples of inspecting req.URL
via newCustomClient
, so I've ditched the one-time helper in 8c9b10a99ae18f95efd5f7b17f5f857aceba3ea2
I think this way is more consistent with the rest of the existing tests, so let me know what you think.
Looks great. Thanks for the contribution! I'll roll a patch release shortly.
Currently,
url.PathEncode
is applied forCreateDB
andDestroyDB
, but not forDBExists
, which behave inconsistently.I discovered this when I created a database that included special characters, but
DBExists
would not correctly detect a database even after being created.For a reproducible example, I could not find a good test case to update, as the request path is never part of the test assertion. You can reproduce the issue with the following setup:
docker-compose.yml
go.mod
main.go
Upon running my "test" script, I get the following output:
This PR includes a fix, which is to use
url.PathEscape
withinDBExists
which mirrorsCreateDB
andDestroyDB
and will produce consistent/correct behavior.It would be nice to validate this fix with a test case, but I don't think the current test suite really has this kind of assertion baked in (it kinda assumes the right URL path is used, since it just returns the configured
*http.Response
no matter what the request).