(t *testing.T)
| 581 | } |
| 582 | |
| 583 | func TestDefaultContainer_ContainsSingleton(t *testing.T) { |
| 584 | testCases := []struct { |
| 585 | name string |
| 586 | preCondition func(container Container) |
| 587 | singletonName string |
| 588 | |
| 589 | wantResult bool |
| 590 | }{ |
| 591 | { |
| 592 | name: "no singleton", |
| 593 | singletonName: "anySingletonName", |
| 594 | wantResult: false, |
| 595 | }, |
| 596 | { |
| 597 | name: "valid singleton", |
| 598 | preCondition: func(container Container) { |
| 599 | _ = container.RegisterSingleton("anySingletonName", AnyComponent{}) |
| 600 | }, |
| 601 | singletonName: "anySingletonName", |
| 602 | wantResult: true, |
| 603 | }, |
| 604 | } |
| 605 | |
| 606 | for _, tc := range testCases { |
| 607 | t.Run(tc.name, func(t *testing.T) { |
| 608 | // given |
| 609 | container := NewDefaultContainer() |
| 610 | |
| 611 | if tc.preCondition != nil { |
| 612 | tc.preCondition(container) |
| 613 | } |
| 614 | |
| 615 | // when |
| 616 | exists := container.ContainsSingleton(tc.singletonName) |
| 617 | |
| 618 | // then |
| 619 | require.Equal(t, tc.wantResult, exists) |
| 620 | }) |
| 621 | } |
| 622 | } |
| 623 | |
| 624 | func TestDefaultContainer_Singleton(t *testing.T) { |
| 625 | anySingleton := &AnyComponent{} |
nothing calls this directly
no test coverage detected