File: pooled_test.rb

package info (click to toggle)
ruby-redis-client 0.28.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,116 kB
  • sloc: ansic: 7,517; ruby: 5,801; makefile: 246; sh: 123
file content (24 lines) | stat: -rw-r--r-- 632 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# frozen_string_literal: true

require "test_helper"

class RedisPooledClientTest < RedisClientTestCase
  include ClientTestHelper
  include RedisClientTests

  def test_checkout_timeout
    pool = RedisClient.config(**tcp_config).new_pool(size: 1, timeout: 0.01)
    Thread.new { pool.instance_variable_get(:@pool).checkout }.join

    error = assert_raises RedisClient::ConnectionError do
      pool.with {}
    end
    assert_includes error.message, "Couldn't checkout a connection in time: Waited 0.01 sec"
  end

  private

  def new_client(**overrides)
    RedisClient.config(**tcp_config.merge(overrides)).new_pool
  end
end