(t *testing.T)
| 25 | ) |
| 26 | |
| 27 | func 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 | |
| 76 | func TestConditionalLoader_Load(t *testing.T) { |
| 77 | anyComponentDef, _ := MakeDefinition(NewAnyComponent) |
nothing calls this directly
no test coverage detected