MCPcopy Create free account
hub / github.com/codnect/procyon / TestDefaultContainer_RemoveSingleton

Function TestDefaultContainer_RemoveSingleton

component/container_test.go:671–716  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

669}
670
671func TestDefaultContainer_RemoveSingleton(t *testing.T) {
672 testCases := []struct {
673 name string
674 preCondition func(container Container)
675 singletonName string
676
677 wantErr error
678 }{
679 {
680 name: "no singleton",
681 singletonName: "anySingletonName",
682 wantErr: ErrInstanceNotFound,
683 },
684 {
685 name: "valid singleton",
686 preCondition: func(container Container) {
687 _ = container.RegisterSingleton("anySingletonName", AnyComponent{})
688 },
689 singletonName: "anySingletonName",
690 wantErr: nil,
691 },
692 }
693
694 for _, tc := range testCases {
695 t.Run(tc.name, func(t *testing.T) {
696 // given
697 container := NewDefaultContainer()
698
699 if tc.preCondition != nil {
700 tc.preCondition(container)
701 }
702
703 // when
704 err := container.RemoveSingleton(tc.singletonName)
705
706 // then
707 if tc.wantErr != nil {
708 require.Error(t, err)
709 require.EqualError(t, err, tc.wantErr.Error())
710 return
711 }
712
713 assert.NoError(t, err)
714 })
715 }
716}
717
718func TestDefaultContainer_CanResolve(t *testing.T) {
719 var testCases = []struct {

Callers

nothing calls this directly

Calls 4

RegisterSingletonMethod · 0.95
RemoveSingletonMethod · 0.95
NewDefaultContainerFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected