TestClearWithFuncLock tests the ClearWithFuncLock method
(t *testing.T)
| 702 | |
| 703 | // TestClearWithFuncLock tests the ClearWithFuncLock method |
| 704 | func TestClearWithFuncLock(t *testing.T) { |
| 705 | slm := NewShardLockMaps() |
| 706 | slm.Set("key1", "value1") |
| 707 | slm.Set("key2", "value2") |
| 708 | |
| 709 | var clearedKeys []string |
| 710 | slm.ClearWithFuncLock(func(key string, val interface{}) { |
| 711 | clearedKeys = append(clearedKeys, key) |
| 712 | }) |
| 713 | |
| 714 | if len(clearedKeys) != 2 { |
| 715 | t.Error("Expected 2 keys to be cleared") |
| 716 | } |
| 717 | if slm.Count() != 0 { |
| 718 | t.Error("Expected map to be empty after ClearWithFuncLock") |
| 719 | } |
| 720 | } |
nothing calls this directly
no test coverage detected