(t *testing.T)
| 302 | } |
| 303 | |
| 304 | func TestMutexLockUnlockSplit(t *testing.T) { |
| 305 | ctx := context.Background() |
| 306 | for k, v := range makeCases(4) { |
| 307 | t.Run(k, func(t *testing.T) { |
| 308 | rs := New(v.pools...) |
| 309 | key := "test-split-lock" |
| 310 | |
| 311 | mutex1 := rs.NewMutex(key, WithExpiry(time.Hour)) |
| 312 | err := mutex1.Lock() |
| 313 | if err != nil { |
| 314 | t.Fatalf("mutex lock failed: %s", err) |
| 315 | } |
| 316 | assertAcquired(ctx, t, v.pools, mutex1) |
| 317 | |
| 318 | mutex2 := rs.NewMutex(key, WithExpiry(time.Hour), WithValue(mutex1.Value())) |
| 319 | ok, err := mutex2.Unlock() |
| 320 | if err != nil { |
| 321 | t.Fatalf("mutex unlock failed: %s", err) |
| 322 | } |
| 323 | if !ok { |
| 324 | t.Fatalf("Expected a valid mutex") |
| 325 | } |
| 326 | }) |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | func getPoolValues(ctx context.Context, pools []redis.Pool, name string) []string { |
| 331 | values := make([]string, len(pools)) |
nothing calls this directly
no test coverage detected
searching dependent graphs…