effectiveLifetimeForRouting resolves a mock's Lifetime for routing purposes, applying the legacy-tag fallback when the cached enum is not explicitly derived. Mirrors the "defensive fallback" branch of filterByTimeStampTierAware but returns a value instead of mutating the mock — the caller decides wh
(m *models.Mock)
| 3525 | // integration stamped Lifetime at emit time, AND for mocks constructed |
| 3526 | // inline by tests that set metadata but never called DeriveLifetime. |
| 3527 | func effectiveLifetimeForRouting(m *models.Mock) models.Lifetime { |
| 3528 | if m == nil { |
| 3529 | return models.LifetimePerTest |
| 3530 | } |
| 3531 | // Explicit non-zero Lifetime wins regardless of LifetimeDerived. |
| 3532 | // This honours recorder-stamped values AND any DeriveLifetime path |
| 3533 | // that cached a non-zero enum without setting the derived bool. |
| 3534 | if m.TestModeInfo.Lifetime == models.LifetimeSession || |
| 3535 | m.TestModeInfo.Lifetime == models.LifetimeConnection { |
| 3536 | return m.TestModeInfo.Lifetime |
| 3537 | } |
| 3538 | if m.TestModeInfo.LifetimeDerived { |
| 3539 | return m.TestModeInfo.Lifetime |
| 3540 | } |
| 3541 | if m.Spec.Metadata != nil { |
| 3542 | switch m.Spec.Metadata["type"] { |
| 3543 | case "config": |
| 3544 | return models.LifetimeSession |
| 3545 | case "connection": |
| 3546 | return models.LifetimeConnection |
| 3547 | } |
| 3548 | } |
| 3549 | return models.LifetimePerTest |
| 3550 | } |
| 3551 | |
| 3552 | func filterByMapping(_ context.Context, logger *zap.Logger, m []*models.Mock, mocksPresentInMapping []string) ([]*models.Mock, []*models.Mock) { |
| 3553 | mapping := make(map[string]bool, len(mocksPresentInMapping)) |
no outgoing calls
no test coverage detected