MCPcopy Create free account
hub / github.com/kataras/iris / TestDependentDependencyInheritanceStatic

Function TestDependentDependencyInheritanceStatic

hero/dependency_test.go:177–211  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

175}
176
177func TestDependentDependencyInheritanceStatic(t *testing.T) {
178 // Tests the following case #1564:
179 // Logger
180 // func(Logger) S1
181 // ^ Should be static because Logger
182 // is a structure, a static dependency.
183 //
184 // func(Logger) S2
185 // func(S1, S2) S3
186 // ^ Should be marked as static dependency
187 // because everything that depends on are static too.
188
189 type S1 struct {
190 msg string
191 }
192
193 type S2 struct {
194 msg2 string
195 }
196
197 serviceDep := NewDependency(&testServiceImpl{prefix: "1"})
198 d1 := NewDependency(func(t testService) S1 {
199 return S1{t.Say("2")}
200 }, serviceDep)
201 if !d1.Static {
202 t.Fatalf("d1 dependency should be static: %#+v", d1)
203 }
204
205 d2 := NewDependency(func(t testService, s S1) S2 {
206 return S2{"3"}
207 }, serviceDep, d1)
208 if !d2.Static {
209 t.Fatalf("d2 dependency should be static: %#+v", d2)
210 }
211}

Callers

nothing calls this directly

Calls 3

NewDependencyFunction · 0.85
FatalfMethod · 0.80
SayMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…