Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
joesonw committed Nov 12, 2020
1 parent a771bac commit 0816a67
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 4 additions & 1 deletion with_annotated.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package fx

import (
"errors"
"fmt"
"reflect"
)
Expand Down Expand Up @@ -61,7 +62,9 @@ func WithAnnotated(names ...string) func(interface{}) interface{} {
userFunc := reflect.ValueOf(f)
userFuncType := userFunc.Type()
if userFuncType.Kind() != reflect.Func {
panic("WithAnnotated returned function must be called with a function")
return func() error {
return errors.New("WithAnnotated returned function must be called with a function")
}
}
numArgs := userFuncType.NumIn()
digInStructFields := []reflect.StructField{{
Expand Down
5 changes: 2 additions & 3 deletions with_annotated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
package fx_test

import (
"context"
"testing"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -92,8 +91,8 @@ func TestWithAnnotatedError(t *testing.T) {
),
fx.Invoke(fx.WithAnnotated("foo")("")),
)
err := app.Start(context.TODO())
err := app.Err()
require.Error(t, err)
assert.Contains(t, err.Error(), " WithAnnotated returned function must be called with a function")
assert.Contains(t, err.Error(), "WithAnnotated returned function must be called with a function")
})
}

0 comments on commit 0816a67

Please sign in to comment.