h2non / gock

HTTP traffic mocking and testing made easy in Go ༼ʘ̚ل͜ʘ̚༽

Home Page:https://pkg.go.dev/github.com/h2non/gock

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

use JSON() as post body matcher, does the order of fields in the body affect matching result

CodeplayerGm opened this issue · comments

sample:
gock.New("https://gitlab.com").
Post("/oauth/token").
Persist().
//JSON(map[string]interface{}{
// "client_id": "12345",
// "client_secret": "12345",
// "code": "mock_code",
// "grant_type": "authorization_code"
//}).
Reply(200).
SetHeader("Content-type", "application/json; charset=utf-8").
BodyString(accessTokenBody)

what if the real request body has different order
{
"client_id": "12345",
"code": "mock_code",
"client_secret": "12345",
"grant_type": "authorization_code"
}

is it possible to provide a tool to transfer request cmd(curl) to code template?