| 48 | } |
| 49 | |
| 50 | func TestLocker_Unlock_Success(t *testing.T) { |
| 51 | db, mock := redismock.NewClientMock() |
| 52 | locker := NewLocker(db, "test-key", "test-value") |
| 53 | |
| 54 | // Simulate a successful unlock |
| 55 | script := "if redis.call('get', KEYS[1]) == ARGV[1] then return redis.call('del', KEYS[1]) else return 0 end" |
| 56 | mock.ExpectEval(script, []string{"test-key"}, "test-value").SetVal(int64(1)) |
| 57 | |
| 58 | err := locker.Unlock(context.Background()) |
| 59 | assert.NoError(t, err) |
| 60 | assert.NoError(t, mock.ExpectationsWereMet()) |
| 61 | } |
| 62 | |
| 63 | func TestLocker_Unlock_Failure(t *testing.T) { |
| 64 | db, mock := redismock.NewClientMock() |