(t *testing.T)
| 87 | } |
| 88 | |
| 89 | func TestLocker_ExtendLock_Failure(t *testing.T) { |
| 90 | db, mock := redismock.NewClientMock() |
| 91 | locker := NewLocker(db, "test-key", "test-value") |
| 92 | |
| 93 | // Simulate failed lock extension (either lock expired or not the holder) |
| 94 | script := "if redis.call('get', KEYS[1]) == ARGV[1] then return redis.call('pexpire', KEYS[1], ARGV[2]) else return 0 end" |
| 95 | mock.ExpectEval(script, []string{"test-key"}, "test-value", "5000").SetVal(int64(0)) |
| 96 | |
| 97 | err := locker.ExtendLock(context.Background(), 5*time.Second) |
| 98 | assert.EqualError(t, err, "lock extension failed for key test-key, either lock expired or you're not the holder") |
| 99 | assert.NoError(t, mock.ExpectationsWereMet()) |
| 100 | } |
| 101 | |
| 102 | func TestLocker_WaitLock_Success(t *testing.T) { |
| 103 | db, mock := redismock.NewClientMock() |
nothing calls this directly
no test coverage detected