fix(couchdb): use url.PathEscape in DBExists for consistency with other DB* methods #1041
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.
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:
$ go run . exists (got false, expected true) exists with hack (got true, expected true)
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).