| 503 | } |
| 504 | |
| 505 | func TestContainer_Fill_Unexported_With_Struct_Pointer(t *testing.T) { |
| 506 | err := instance.Singleton(func() Shape { |
| 507 | return &Circle{a: 5} |
| 508 | }) |
| 509 | assert.NoError(t, err) |
| 510 | |
| 511 | err = instance.Singleton(func() Database { |
| 512 | return &MySQL{} |
| 513 | }) |
| 514 | assert.NoError(t, err) |
| 515 | |
| 516 | myApp := struct { |
| 517 | s Shape `container:"type"` |
| 518 | d Database `container:"type"` |
| 519 | y int |
| 520 | }{} |
| 521 | |
| 522 | err = instance.Fill(&myApp) |
| 523 | assert.NoError(t, err) |
| 524 | |
| 525 | assert.IsType(t, &Circle{}, myApp.s) |
| 526 | assert.IsType(t, &MySQL{}, myApp.d) |
| 527 | } |
| 528 | |
| 529 | func TestContainer_Fill_With_Invalid_Field_It_Should_Fail(t *testing.T) { |
| 530 | err := instance.NamedSingleton("C", func() Shape { |