Skip to content

Commit

Permalink
doc: enhance comment
Browse files Browse the repository at this point in the history
  • Loading branch information
maxatome authored Jan 27, 2021
1 parent 2220adb commit d1b2862
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions response.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,29 @@ func ResponderFromResponse(resp *http.Response) Responder {
// For home-made responses, NewRespBodyFromString and
// NewRespBodyFromBytes functions can be used to produce response
// bodies that can be read several times and concurrently.
//
// If all responses have been returned and fn is passed
// and non-nil, it acts as the fn parameter of NewNotFoundResponder,
// allowing to dump the stack trace to localize the origin of the
// call.
// import (
// "github.com/jarcoal/httpmock"
// "testing"
// )
// ...
// func TestMyApp(t *testing.T) {
// ...
// // This responder is callable only once, then an error is returned and
// // the stacktrace of the call logged using t.Log()
// httpmock.RegisterResponder("GET", "/foo/bar",
// httpmock.ResponderFromMultipleResponses(
// []*http.Response{
// httpmock.NewStringResponse(200, `{"name":"bar"}`),
// httpmock.NewStringResponse(404, `{"mesg":"Not found"}`),
// },
// t.Log),
// )
// }
func ResponderFromMultipleResponses(responses []*http.Response, fn ...func(...interface{})) Responder {
responseIndex := 0
mutex := sync.Mutex{}
Expand Down

0 comments on commit d1b2862

Please sign in to comment.