(t *testing.T)
| 175 | } |
| 176 | |
| 177 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…