Commit 4bd0f29e authored by Johnny's avatar Johnny

fix: resolve linter warning and cache race condition

- Suppress revive redundant-test-main-exit warning with //nolint
- Fix data race in cache.Clear() by using Delete() instead of map replacement
- Both changes maintain correct behavior while fixing CI failures
parent db57f445
......@@ -161,20 +161,20 @@ func (c *Cache) Delete(_ context.Context, key string) {
// Clear removes all values from the cache.
func (c *Cache) Clear(_ context.Context) {
if c.config.OnEviction != nil {
count := 0
c.data.Range(func(key, value any) bool {
if c.config.OnEviction != nil {
itm, ok := value.(item)
if !ok {
return true
}
if ok {
if keyStr, ok := key.(string); ok {
c.config.OnEviction(keyStr, itm.value)
}
}
}
c.data.Delete(key)
count++
return true
})
}
c.data = sync.Map{}
(&c.itemCount).Store(0)
}
......
......@@ -13,7 +13,8 @@ func TestMain(m *testing.M) {
// If DRIVER is set, run tests for that driver only
if os.Getenv("DRIVER") != "" {
defer TerminateContainers()
os.Exit(m.Run())
m.Run() //nolint:revive // Exit code is handled by test runner
return
}
// No DRIVER set - run tests for all drivers sequentially
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment