1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-21 20:07:04 +00:00

New APIContainer.EnableStrictMode(bool) method. Read HISTORY.md

This commit is contained in:
Gerasimos (Makis) Maropoulos
2021-04-22 14:00:00 +03:00
parent 43079f75d2
commit 6219e57135
9 changed files with 124 additions and 47 deletions

View File

@@ -269,7 +269,7 @@ func TestGetBindingsForFunc(t *testing.T) {
}
for i, tt := range tests {
bindings := getBindingsForFunc(reflect.ValueOf(tt.Func), c.Dependencies, 0)
bindings := getBindingsForFunc(reflect.ValueOf(tt.Func), c.Dependencies, c.DisablePayloadAutoBinding, 0)
if expected, got := len(tt.Expected), len(bindings); expected != got {
t.Fatalf("[%d] expected bindings length to be: %d but got: %d of: %s", i, expected, got, bindings)
@@ -524,7 +524,7 @@ func TestBindingsForStruct(t *testing.T) {
}
for i, tt := range tests {
bindings := getBindingsForStruct(reflect.ValueOf(tt.Value), tt.Registered, 0, nil)
bindings := getBindingsForStruct(reflect.ValueOf(tt.Value), tt.Registered, false, false, 0, nil)
if expected, got := len(tt.Expected), len(bindings); expected != got {
t.Logf("[%d] expected bindings length to be: %d but got: %d:\n", i, expected, got)
@@ -546,3 +546,24 @@ func TestBindingsForStruct(t *testing.T) {
}
}
func TestBindingsForStructMarkExportedFieldsAsRequred(t *testing.T) {
type (
Embedded struct {
Val string
}
controller struct {
MyService service
Embedded *Embedded
}
)
dependencies := []*Dependency{
NewDependency(&Embedded{"test"}),
NewDependency(&serviceImpl{}),
}
// should panic if fail.
_ = getBindingsForStruct(reflect.ValueOf(new(controller)), dependencies, true, true, 0, nil)
}