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

Function TestNewConditionalLoader

component/loader_test.go:27–74  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

25)
26
27func TestNewConditionalLoader(t *testing.T) {
28 testCases := []struct {
29 name string
30 ctx context.Context
31 container Container
32 components []*Component
33 wantPanic error
34 }{
35 {
36 name: "nil container",
37 ctx: context.Background(),
38 container: nil,
39 components: []*Component{},
40 wantPanic: errors.New("nil container"),
41 },
42 {
43 name: "valid container",
44 ctx: context.Background(),
45 container: NewDefaultContainer(),
46 components: []*Component{},
47 },
48 {
49 name: "nil components",
50 ctx: context.Background(),
51 container: NewDefaultContainer(),
52 components: nil,
53 },
54 }
55
56 for _, tc := range testCases {
57 t.Run(tc.name, func(t *testing.T) {
58 // given
59
60 // when
61 if tc.wantPanic != nil {
62 require.PanicsWithValue(t, tc.wantPanic.Error(), func() {
63 NewConditionalLoader(tc.container, tc.components)
64 })
65 return
66 }
67
68 loader := NewConditionalLoader(tc.container, tc.components)
69
70 // then
71 require.NotNil(t, loader)
72 })
73 }
74}
75
76func TestConditionalLoader_Load(t *testing.T) {
77 anyComponentDef, _ := MakeDefinition(NewAnyComponent)

Callers

nothing calls this directly

Calls 3

NewDefaultContainerFunction · 0.85
NewConditionalLoaderFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected