test dynfunc package; standardize and refactor api #14
|
@ -17,6 +17,9 @@ const ErrNoServiceForHandler = cerr("no service found for this handler")
|
|||
// ErrMissingHandlerArgumentParam - missing params arguments for handler
|
||||
const ErrMissingHandlerArgumentParam = cerr("missing handler argument : parameter struct")
|
||||
|
||||
// ErrUnexpectedInput - input argument is not expected
|
||||
const ErrUnexpectedInput = cerr("unexpected input struct")
|
||||
|
||||
// ErrMissingHandlerOutput - missing output for handler
|
||||
const ErrMissingHandlerOutput = cerr("handler must have at least 1 output")
|
||||
|
||||
|
|
|
@ -44,6 +44,9 @@ func (s spec) checkInput(fnv reflect.Value) error {
|
|||
|
||||
// no input -> ok
|
||||
if len(s.Input) == 0 {
|
||||
if fnt.NumIn() > 0 {
|
||||
return ErrUnexpectedInput
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -21,11 +21,11 @@ func TestInputCheck(t *testing.T) {
|
|||
Fn: func() {},
|
||||
Err: nil,
|
||||
},
|
||||
// func can have any arguments if not specified
|
||||
// func must have noarguments if none specified
|
||||
{
|
||||
Input: map[string]reflect.Type{},
|
||||
Fn: func(int, string) {},
|
||||
Err: nil,
|
||||
Err: ErrUnexpectedInput,
|
||||
},
|
||||
// missing input struct in func
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue