(t *testing.T)
| 577 | } |
| 578 | |
| 579 | func TestContainer_Fill_With_Dependency_Missing_In_Chain(t *testing.T) { |
| 580 | var instance = container.New() |
| 581 | err := instance.Singleton(func() Shape { |
| 582 | return &Circle{a: 5} |
| 583 | }) |
| 584 | assert.NoError(t, err) |
| 585 | |
| 586 | err = instance.NamedSingletonLazy("C", func() (Shape, error) { |
| 587 | var s Shape |
| 588 | if err := instance.NamedResolve(&s, "foo"); err != nil { |
| 589 | return nil, err |
| 590 | } |
| 591 | return &Circle{a: 5}, nil |
| 592 | }) |
| 593 | assert.NoError(t, err) |
| 594 | |
| 595 | err = instance.Singleton(func() Database { |
| 596 | return &MySQL{} |
| 597 | }) |
| 598 | assert.NoError(t, err) |
| 599 | |
| 600 | myApp := struct { |
| 601 | S Shape `container:"type"` |
| 602 | D Database `container:"type"` |
| 603 | C Shape `container:"name"` |
| 604 | X string |
| 605 | }{} |
| 606 | |
| 607 | err = instance.Fill(&myApp) |
| 608 | assert.EqualError(t, err, "container: no concrete found for: container_test.Shape") |
| 609 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…