h2non / gock

HTTP traffic mocking and testing made easy in Go ༼ʘ̚ل͜ʘ̚༽
https://pkg.go.dev/github.com/h2non/gock
MIT License
2.04k stars 106 forks source link

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

Open CodeplayerGm opened 1 year ago

CodeplayerGm commented 1 year ago

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" }

CodeplayerGm commented 1 year ago

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