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

Function TestDefaultContainer_ContainsSingleton

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

Source from the content-addressed store, hash-verified

581}
582
583func 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
624func TestDefaultContainer_Singleton(t *testing.T) {
625 anySingleton := &AnyComponent{}

Callers

nothing calls this directly

Calls 4

RegisterSingletonMethod · 0.95
ContainsSingletonMethod · 0.95
NewDefaultContainerFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected