Here is the new feature for mocking different mock requests.
Some go libs make HTTP requests with different query items in url.
example for huandu/facebook lib:
// sometimes:
GET http://graph.facebook.com/insights?ids=1,2,3&access_token=123123
// sometimes:
GET http://graph.facebook.com/insights?access_token=123123&ids=1,2,3
The current mock implementation doesn't allow handle this types of requests. My PR allows to pass query items as map and it will always match despite of order.
Usage example:
func TestFetchArticles(t *testing.T) {
httpmock.Activate()
httpmock.DeactivateAndReset()
expecedQuery := map[string]string{
"a": "1",
"b": "2"
}
httpmock.RegisterResponderWithQuery("GET", "http://example.com/", expecedQuery,
httpmock.NewStringResponder("hello world", 200))
// requests to http://example.com?a=1&b=2 and http://example.com?b=2&a=1 will now return 'hello world'
}
Here is the new feature for mocking different mock requests. Some go libs make HTTP requests with different query items in url. example for
huandu/facebook
lib:The current mock implementation doesn't allow handle this types of requests. My PR allows to pass query items as map and it will always match despite of order.
Usage example:
We are using my modification in production.