Skip to content
This repository was archived by the owner on Jan 18, 2021. It is now read-only.

Commit

Permalink
Fix non pointer struct type providing
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim Bovtunov committed Dec 11, 2019
1 parent e84d64c commit fe23fdf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
14 changes: 14 additions & 0 deletions di/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ func TestContainerCompileErrors(t *testing.T) {
c.MustProvide(ditest.NewBar)
c.MustCompileError("*ditest.Bar: dependency *ditest.Foo not exists in container")
})

t.Run("not existing non pointer dependency cause compile error", func(t *testing.T) {
c := NewTestContainer(t)
type TestStruct struct {
}

c.MustProvide(func(s TestStruct) bool {
return true
})

require.PanicsWithValue(t, "bool: dependency di_test.TestStruct not exists in container", func() {
c.Compile()
})
})
}

func TestContainerProvideErrors(t *testing.T) {
Expand Down
4 changes: 3 additions & 1 deletion di/parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ func (pl parameterList) resolve(c *Container) ([]reflect.Value, error) {
}

// internalParameter
type internalParameter interface{}
type internalParameter interface {
isDependencyInjectionParameter()
}

var parameterInterface = reflect.TypeOf(new(internalParameter)).Elem()

Expand Down

0 comments on commit fe23fdf

Please sign in to comment.