1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 18:37:05 +00:00
Former-commit-id: d17b205a56f95f476db8b846c88b4cb6df8b5239
This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-07-24 16:50:00 +03:00
parent c3205dafa1
commit baf68391b5
4 changed files with 63 additions and 1 deletions

View File

@@ -168,3 +168,39 @@ func testDependencies(t *testing.T, tests []testDependencyTest) {
// t.Logf("[%d] output: %#+v", i, val.Interface())
}
}
func TestDependentDependencyInheritanceStatic(t *testing.T) {
// Tests the following case #1564:
// Logger
// func(Logger) S1
// ^ Should be static because Logger
// is a structure, a static dependency.
//
// func(Logger) S2
// func(S1, S2) S3
// ^ Should be marked as static dependency
// because everything that depends on are static too.
type S1 struct {
msg string
}
type S2 struct {
msg2 string
}
serviceDep := NewDependency(&testServiceImpl{prefix: "1"})
d1 := NewDependency(func(t testService) S1 {
return S1{t.Say("2")}
}, serviceDep)
if !d1.Static {
t.Fatalf("d1 dependency should be static: %#+v", d1)
}
d2 := NewDependency(func(t testService, s S1) S2 {
return S2{"3"}
}, serviceDep, d1)
if !d2.Static {
t.Fatalf("d2 dependency should be static: %#+v", d2)
}
}