send requestBody to mock function if it can handle it
This commit is contained in:
parent
e4704a8f41
commit
c1c0a8fb30
@ -83,7 +83,11 @@ func (m *MockClient) Call(ctx context.Context, req client.Request, rsp interface
|
||||
}
|
||||
response := r.Response
|
||||
if t := reflect.TypeOf(r.Response); t.Kind() == reflect.Func {
|
||||
response = reflect.ValueOf(r.Response).Call([]reflect.Value{})[0].Interface()
|
||||
var reqBody []reflect.Value
|
||||
if t.NumIn() == 0 {
|
||||
reqBody = append(reqBody, reflect.ValueOf(req.Body()))
|
||||
}
|
||||
response = reflect.ValueOf(r.Response).Call(reqBody)[0].Interface()
|
||||
}
|
||||
|
||||
v.Set(reflect.ValueOf(response))
|
||||
|
Loading…
Reference in New Issue
Block a user