Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobOaks committed May 14, 2024
1 parent c2ff838 commit 724bb8d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
1 change: 0 additions & 1 deletion annotated.go
Original file line number Diff line number Diff line change
Expand Up @@ -1527,7 +1527,6 @@ type annotated struct {
ParamTags []string
ResultTags []string
As [][]asType
AsSelf bool
From []reflect.Type
FuncPtr uintptr
Hooks []*lifecycleHookAnnotation
Expand Down
22 changes: 22 additions & 0 deletions annotated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,28 @@ func TestAnnotatedAs(t *testing.T) {
assert.NoError(t, err)
},
},
{
desc: "two as, two self, four types",
provide: fx.Provide(
fx.Annotate(
func() (*asStringer, *bytes.Buffer) {
s := &asStringer{name: "stringer"}
b := &bytes.Buffer{}
return s, b
},
fx.As(fx.Self(), new(io.Writer)),
fx.As(new(fmt.Stringer)),
),
),
invoke: func(s1 *asStringer, s2 fmt.Stringer, b *bytes.Buffer, w io.Writer) {
assert.Equal(t, "stringer", s1.String())
assert.Equal(t, "stringer", s2.String())
_, err := w.Write([]byte("."))
assert.NoError(t, err)
_, err = b.Write([]byte("."))
assert.NoError(t, err)
},
},
{
desc: "self with lifecycle hook",
provide: fx.Provide(
Expand Down

0 comments on commit 724bb8d

Please sign in to comment.