File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -141,6 +141,29 @@ func ResponderFromResponse(resp *http.Response) Responder {
141141// For home-made responses, NewRespBodyFromString and
142142// NewRespBodyFromBytes functions can be used to produce response
143143// bodies that can be read several times and concurrently.
144+ //
145+ // If all responses have been returned and fn is passed
146+ // and non-nil, it acts as the fn parameter of NewNotFoundResponder,
147+ // allowing to dump the stack trace to localize the origin of the
148+ // call.
149+ // import (
150+ // "github.com/jarcoal/httpmock"
151+ // "testing"
152+ // )
153+ // ...
154+ // func TestMyApp(t *testing.T) {
155+ // ...
156+ // // This responder is callable only once, then an error is returned and
157+ // // the stacktrace of the call logged using t.Log()
158+ // httpmock.RegisterResponder("GET", "/foo/bar",
159+ // httpmock.ResponderFromMultipleResponses(
160+ // []*http.Response{
161+ // httpmock.NewStringResponse(200, `{"name":"bar"}`),
162+ // httpmock.NewStringResponse(404, `{"mesg":"Not found"}`),
163+ // },
164+ // t.Log),
165+ // )
166+ // }
144167func ResponderFromMultipleResponses (responses []* http.Response , fn ... func (... interface {})) Responder {
145168 responseIndex := 0
146169 mutex := sync.Mutex {}
You can’t perform that action at this time.
0 commit comments