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)
| 521 | // restoring the original state via t.Cleanup. This prevents extension registrations |
| 522 | // in one test from leaking into others. |
| 523 | func 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 | |
| 540 | var _ Extension = (*testExtension)(nil) |
| 541 |
no outgoing calls
no test coverage detected