test/test_zache.rb in zache-0.5.0 vs test/test_zache.rb in zache-0.5.1
- old
+ new
@@ -23,12 +23,15 @@
# SOFTWARE.
require 'minitest/autorun'
require 'threads'
require 'timeout'
+require 'concurrent'
require_relative '../lib/zache'
+Thread.report_on_exception = true
+
# Cache test.
# Author:: Yegor Bugayenko (yegor256@gmail.com)
# Copyright:: Copyright (c) 2018 Yegor Bugayenko
# License:: MIT
class ZacheTest < Minitest::Test
@@ -194,7 +197,17 @@
sleep 0.1
Timeout.timeout(1) do
assert_equal(1, cache.get(:first, dirty: true) { 2 })
end
long.kill
+ end
+
+ def test_fetches_multiple_keys_in_many_threads
+ cache = Zache.new(dirty: true)
+ set = Concurrent::Set.new
+ threads = 50
+ Threads.new(threads).assert(threads * 2) do |i|
+ set << cache.get(i) { i }
+ end
+ assert_equal(threads, set.size)
end
end