MCPcopy Create free account
hub / github.com/golobby/container / TestContainer_Fill_With_Dependency_Missing_In_Chain

Function TestContainer_Fill_With_Dependency_Missing_In_Chain

container_test.go:579–609  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

577}
578
579func 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}

Callers

nothing calls this directly

Calls 4

SingletonMethod · 0.80
NamedSingletonLazyMethod · 0.80
NamedResolveMethod · 0.80
FillMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…