(t *testing.T)
| 261 | } |
| 262 | |
| 263 | func TestLock_Refresh_retry_transient_error(t *testing.T) { |
| 264 | rc := redisConnect(t) |
| 265 | flaky := &flakyScripter{Client: rc.Client} |
| 266 | client := New(flaky) |
| 267 | |
| 268 | lock, err := client.Obtain(t.Context(), rc.lockKey(), time.Hour, nil) |
| 269 | if err != nil { |
| 270 | t.Fatal(err) |
| 271 | } |
| 272 | defer lock.Release(t.Context()) |
| 273 | |
| 274 | // fail the next 2 refresh attempts; the 3rd should succeed. |
| 275 | flaky.fails.Store(2) |
| 276 | if err := lock.Refresh(t.Context(), time.Minute, &Options{ |
| 277 | RetryStrategy: LimitRetry(LinearBackoff(5*time.Millisecond), 5), |
| 278 | }); err != nil { |
| 279 | t.Fatalf("expected refresh to recover, got %v", err) |
| 280 | } |
| 281 | if remaining := flaky.fails.Load(); remaining != 0 { |
| 282 | t.Fatalf("expected all injected failures to be consumed, %d remaining", remaining) |
| 283 | } |
| 284 | assertTTL(t, lock, time.Minute) |
| 285 | } |
| 286 | |
| 287 | func TestLock_Refresh_retry_transient_error_exhausted(t *testing.T) { |
| 288 | rc := redisConnect(t) |
nothing calls this directly
no test coverage detected