MCPcopy
hub / github.com/grafana/tempo / resetRegistryForTesting

Function resetRegistryForTesting

modules/overrides/extension_test.go:523–538  ·  view source on GitHub ↗

resetRegistryForTesting clears the extension registry for the duration of the test, restoring the original state via t.Cleanup. This prevents extension registrations in one test from leaking into others.

(t *testing.T)

Source from the content-addressed store, hash-verified

521// restoring the original state via t.Cleanup. This prevents extension registrations
522// in one test from leaking into others.
523func resetRegistryForTesting(t *testing.T) {
524 t.Helper()
525 extensionRegistry.Lock()
526 savedEntries := extensionRegistry.entries
527 savedLegacyKeys := extensionRegistry.allLegacyKeys
528 extensionRegistry.entries = make(map[string]*registryEntry)
529 extensionRegistry.allLegacyKeys = make(map[string]struct{})
530 extensionRegistry.Unlock()
531
532 t.Cleanup(func() {
533 extensionRegistry.Lock()
534 extensionRegistry.entries = savedEntries
535 extensionRegistry.allLegacyKeys = savedLegacyKeys
536 extensionRegistry.Unlock()
537 })
538}
539
540var _ Extension = (*testExtension)(nil)
541

Calls

no outgoing calls

Tested by

no test coverage detected