Sha256: a1324c4bda955c65a179bc3f77d6458418a4132ae85841b561b9d57441140d22
Contents?: true
Size: 954 Bytes
Versions: 37
Compression:
Stored size: 954 Bytes
Contents
# frozen_string_literal: true require_relative 'helper' class ThrottlerTest < MiniTest::Test def test_throttler_with_rate t = Polyphony::Throttler.new(10) buffer = [] t0 = Time.now f = spin { loop { t.process { buffer << 1 } } } sleep 0.2 f.stop assert_in_range 1..4, buffer.size if IS_LINUX end def test_throttler_with_hash_of_rate t = Polyphony::Throttler.new(rate: 20) buffer = [] f = spin do loop { t.process { buffer << 1 } } end sleep 0.25 f.stop assert_in_range 4..6, buffer.size if IS_LINUX end def test_throttler_with_hash_of_interval t = Polyphony::Throttler.new(interval: 0.01) buffer = [] f = spin { loop { t.process { buffer << 1 } } } sleep 0.02 f.stop assert_in_range 2..4, buffer.size if IS_LINUX end def test_throttler_with_invalid_argument assert_raises RuntimeError do Polyphony::Throttler.new(:foobar) end end end
Version data entries
37 entries across 37 versions & 1 rubygems