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

Function TestContainer_Fill_With_Struct_Pointer

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

Source from the content-addressed store, hash-verified

473}
474
475func TestContainer_Fill_With_Struct_Pointer(t *testing.T) {
476 err := instance.Singleton(func() Shape {
477 return &Circle{a: 5}
478 })
479 assert.NoError(t, err)
480
481 err = instance.NamedSingleton("C", func() Shape {
482 return &Circle{a: 5}
483 })
484 assert.NoError(t, err)
485
486 err = instance.Singleton(func() Database {
487 return &MySQL{}
488 })
489 assert.NoError(t, err)
490
491 myApp := struct {
492 S Shape `container:"type"`
493 D Database `container:"type"`
494 C Shape `container:"name"`
495 X string
496 }{}
497
498 err = instance.Fill(&myApp)
499 assert.NoError(t, err)
500
501 assert.IsType(t, &Circle{}, myApp.S)
502 assert.IsType(t, &MySQL{}, myApp.D)
503}
504
505func TestContainer_Fill_Unexported_With_Struct_Pointer(t *testing.T) {
506 err := instance.Singleton(func() Shape {

Callers

nothing calls this directly

Calls 3

SingletonMethod · 0.80
NamedSingletonMethod · 0.80
FillMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…