MCPcopy Create free account
hub / github.com/aceld/zinx / TestLockFuncWithKey

Function TestLockFuncWithKey

zutils/shard_lock_map_test.go:627–643  ·  view source on GitHub ↗

TestLockFuncWithKey tests the LockFuncWithKey method

(t *testing.T)

Source from the content-addressed store, hash-verified

625
626// TestLockFuncWithKey tests the LockFuncWithKey method
627func TestLockFuncWithKey(t *testing.T) {
628 slm := NewShardLockMaps()
629 slm.Set("key1", "value1")
630 slm.Set("key2", "value2")
631
632 // Test modifying a specific key's shard
633 slm.LockFuncWithKey("key1", func(data map[string]interface{}) {
634 if val, ok := data["key1"]; ok {
635 data["key1"] = val.(string) + "_modified"
636 }
637 })
638
639 value, ok := slm.Get("key1")
640 if !ok || value != "value1_modified" {
641 t.Error("Expected key1 to be modified")
642 }
643}
644
645// TestRLockFuncWithKey tests the RLockFuncWithKey method
646func TestRLockFuncWithKey(t *testing.T) {

Callers

nothing calls this directly

Calls 5

SetMethod · 0.95
LockFuncWithKeyMethod · 0.95
GetMethod · 0.95
NewShardLockMapsFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected