-
Notifications
You must be signed in to change notification settings - Fork 110
Open
Description
since the "ReplyFunc()" provide an entrance to return a response generated by custom function. however, the "mockGithubResponseHandler" executes when the mocker is registered.
is there any way to generate response in runtime, with parameter or options for "ReplyFunc()"?
gock.New("https://github.com").
Post("/login/oauth/access_token").
Persist().
MatchParams(map[string]string{
"client_id": "Iv1.expire0000000000",
"client_secret": "expire0000000000000000000000000000000000",
}).
ReplyFunc(mockGithubResponseHandler)
func mockGithubResponseHandler(r *gock.Response) {
r.Status(200)
r.SetHeader("Content-type", "application/json; charset=utf-8")
if ExpireFlag {
r.BodyString("{expire_at: 1670000000}")
} else {
r.BodyString("{expire_at: 0}")
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels