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

Function TestDefaultContainer_Definition

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

Source from the content-addressed store, hash-verified

317}
318
319func TestDefaultContainer_Definition(t *testing.T) {
320 anyDefinition := &Definition{
321 name: "anyDefinitionName",
322 }
323
324 testCases := []struct {
325 name string
326 preCondition func(container Container)
327 definitionName string
328
329 wantResult bool
330 wantDefinition *Definition
331 }{
332 {
333 name: "no definition",
334 definitionName: "anyDefinitionName",
335 wantResult: false,
336 },
337 {
338 name: "valid definition",
339 preCondition: func(container Container) {
340 _ = container.RegisterDefinition(anyDefinition)
341 },
342 definitionName: "anyDefinitionName",
343 wantResult: true,
344 wantDefinition: anyDefinition,
345 },
346 }
347
348 for _, tc := range testCases {
349 t.Run(tc.name, func(t *testing.T) {
350 // given
351 container := NewDefaultContainer()
352
353 if tc.preCondition != nil {
354 tc.preCondition(container)
355 }
356
357 // when
358 def, exists := container.Definition(tc.definitionName)
359
360 // then
361 require.Equal(t, tc.wantResult, exists)
362 require.Equal(t, tc.wantDefinition, def)
363 })
364 }
365}
366
367func TestDefaultContainer_ContainsDefinition(t *testing.T) {
368 testCases := []struct {

Callers

nothing calls this directly

Calls 4

RegisterDefinitionMethod · 0.95
DefinitionMethod · 0.95
NewDefaultContainerFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected