MCPcopy Create free account
hub / github.com/gotenberg/gotenberg / TestContext_loadModule

Function TestContext_loadModule

pkg/gotenberg/context_test.go:151–217  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

149}
150
151func TestContext_loadModule(t *testing.T) {
152 for _, tc := range []struct {
153 scenario string
154 instance any
155 expectError bool
156 }{
157 {
158 scenario: "module with error on provision",
159 instance: func() any {
160 mod := &struct {
161 ModuleMock
162 ProvisionerMock
163 }{}
164 mod.DescriptorMock = func() ModuleDescriptor {
165 return ModuleDescriptor{ID: "foo", New: func() Module { return mod }}
166 }
167 mod.ProvisionMock = func(ctx *Context) error { return errors.New("foo") }
168 return mod
169 }(),
170 expectError: true,
171 },
172 {
173 scenario: "module with error on validation",
174 instance: func() any {
175 mod := &struct {
176 ModuleMock
177 ValidatorMock
178 }{}
179 mod.DescriptorMock = func() ModuleDescriptor {
180 return ModuleDescriptor{ID: "foo", New: func() Module { return mod }}
181 }
182 mod.ValidateMock = func() error { return errors.New("foo") }
183 return mod
184 }(),
185 expectError: true,
186 },
187 {
188 scenario: "success",
189 instance: func() any {
190 mod := &struct {
191 ModuleMock
192 ValidatorMock
193 }{}
194 mod.DescriptorMock = func() ModuleDescriptor {
195 return ModuleDescriptor{ID: "foo", New: func() Module { return mod }}
196 }
197 mod.ValidateMock = func() error { return nil }
198
199 return mod
200 }(),
201 expectError: false,
202 },
203 } {
204 t.Run(tc.scenario, func(t *testing.T) {
205 ctx := NewContext(ParsedFlags{}, nil)
206 err := ctx.loadModule("foo", tc.instance)
207
208 if !tc.expectError && err != nil {

Callers

nothing calls this directly

Calls 3

loadModuleMethod · 0.95
NewContextFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected