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

Function TestDefaultContainer_Scope

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

Source from the content-addressed store, hash-verified

1248}
1249
1250func TestDefaultContainer_Scope(t *testing.T) {
1251 anyScope := &AnyScope{}
1252
1253 testCases := []struct {
1254 name string
1255 preCondition func(container Container)
1256 scopeName string
1257
1258 wantResult bool
1259 wantScope Scope
1260 }{
1261 {
1262 name: "no scope",
1263 scopeName: "anyScopeName",
1264 wantResult: false,
1265 },
1266 {
1267 name: "valid scope",
1268 preCondition: func(container Container) {
1269 _ = container.RegisterScope("anyScopeName", anyScope)
1270 },
1271 scopeName: "anyScopeName",
1272 wantResult: true,
1273 wantScope: anyScope,
1274 },
1275 }
1276
1277 for _, tc := range testCases {
1278 t.Run(tc.name, func(t *testing.T) {
1279 // given
1280 container := NewDefaultContainer()
1281
1282 if tc.preCondition != nil {
1283 tc.preCondition(container)
1284 }
1285
1286 // when
1287 scope, exists := container.Scope(tc.scopeName)
1288
1289 // then
1290 require.Equal(t, tc.wantResult, exists)
1291 require.Equal(t, tc.wantScope, scope)
1292 })
1293 }
1294}
1295
1296func TestDefaultContainer_UsePreProcessor(t *testing.T) {
1297 testCases := []struct {

Callers

nothing calls this directly

Calls 4

RegisterScopeMethod · 0.95
ScopeMethod · 0.95
NewDefaultContainerFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected