Open Ahmad-Faizan opened 2 years ago
Same happened when I try to match param of date type. Encoded value: 2023-09-23T01%3A28%3A16%2B02%3A00 String value: 2023-09-23T01:28:16+02:00
Hello @Ahmad-Faizan @denizgursoy
gock uses regexp.MatchString()
to match query parameters (code).
Any chars that have a special meaning in a regular expression, like (
, )
or +
, need to be escaped:
// ...
MatchParam("query", `scalar\(testMetric\)`)
// ...
I just learnt that regexp.QuoteMeta method can be used escape special characters in a reqular expression
It seems there is an issue while mocking Prometheus URLs with gock. Prometheus URLs contain a query which is written in PromQL. The resulting URLs look similar to
http://localhost:9090/api/v1/query?query=scalar(anyMetric)
This test fails as long as the
MatchParam()
is present in Line 18 inmain_test.go
I tried passing promQuery variable as a normal string as well as a URL encoded string but the test fails in both the scenarios. Test command -
Is this a issue due to gock ?