From 5d2afa4eaeca6a7ee8dd9c952a8907ef04b45eea Mon Sep 17 00:00:00 2001 From: Michael Nikitochkin Date: Sun, 20 Nov 2022 18:50:56 +0100 Subject: [PATCH] Update liniting warnings --- test/lru_hash_test.rb | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/test/lru_hash_test.rb b/test/lru_hash_test.rb index 53aaf2d02..94351afb8 100644 --- a/test/lru_hash_test.rb +++ b/test/lru_hash_test.rb @@ -61,8 +61,9 @@ def test_set_cleans_resources_if_last_error_has_expired lru_hash = LRUHash.new(max_size: 0, min_time: 1) lru_hash.set("b", create_circuit_breaker("b", true, false, 2)) - sleep 3 + sleep(3) lru_hash.set("d", create_circuit_breaker("d")) + assert_equal(["d"], lru_hash.values.map(&:name)) assert_equal(1, lru_hash.size) end @@ -83,7 +84,7 @@ def test_set_cleans_resources_if_minimum_time_is_reached lru_hash.set("b", create_circuit_breaker("b", false)) lru_hash.set("c", create_circuit_breaker("c", false)) - sleep 2 + sleep(2) lru_hash.set("d", create_circuit_breaker("d")) assert_equal(["a", "d"], lru_hash.values.map(&:name)) @@ -142,8 +143,9 @@ def test_clean_instrumentation refute_nil(payload[:elapsed]) end - sleep 3 + sleep(3) lru_hash.set("d", create_circuit_breaker("d")) + assert(notified, "No notifications has been emitted") ensure Semian.unsubscribe(subscriber) @@ -181,21 +183,25 @@ def test_monotonically_increasing lru_hash.set("a", create_circuit_breaker("a")) lru_hash.set("b", create_circuit_breaker("b")) lru_hash.set("c", create_circuit_breaker("c")) - assert_equal ["a", "b", "c"], lru_hash.values.map(&:name) - sleep 1 + assert_equal(["a", "b", "c"], lru_hash.values.map(&:name)) + + sleep(1) lru_hash.get("b") assert_monotonic.call(lru_hash) - assert_equal ["a", "c", "b"], lru_hash.values.map(&:name) + + assert_equal(["a", "c", "b"], lru_hash.values.map(&:name)) lru_hash.set("d", create_circuit_breaker("d")) assert_monotonic.call(lru_hash) - assert_equal ["a", "c", "b", "d"], lru_hash.values.map(&:name) - sleep 2 + assert_equal(["a", "c", "b", "d"], lru_hash.values.map(&:name)) + + sleep(2) lru_hash.set("e", create_circuit_breaker("e")) assert_monotonic.call(lru_hash) - assert_equal ["b", "d", "e"], lru_hash.values.map(&:name) + + assert_equal(["b", "d", "e"], lru_hash.values.map(&:name)) ensure Semian.unsubscribe(subscriber) end @@ -207,11 +213,12 @@ def test_max_size lru_hash.set("c", create_circuit_breaker("c")) assert_equal(3, lru_hash.size) - assert_equal ["a", "b", "c"], lru_hash.values.map(&:name) + assert_equal(["a", "b", "c"], lru_hash.values.map(&:name)) - sleep 1 + sleep(1) lru_hash.set("d", create_circuit_breaker("d")) - assert_equal ["d"], lru_hash.values.map(&:name) + + assert_equal(["d"], lru_hash.values.map(&:name)) end def test_max_size_overflow @@ -220,22 +227,22 @@ def test_max_size_overflow lru_hash.set("b", create_circuit_breaker("b")) assert_equal(2, lru_hash.size) - assert_equal ["a", "b"], lru_hash.values.map(&:name) + assert_equal(["a", "b"], lru_hash.values.map(&:name)) - sleep 2 + sleep(2) # [a, b] are older than the min_time, but the hash isn't full, so # there's no garbage collection. lru_hash.set("c", create_circuit_breaker("c")) assert_equal(3, lru_hash.size) - assert_equal ["a", "b", "c"], lru_hash.values.map(&:name) + assert_equal(["a", "b", "c"], lru_hash.values.map(&:name)) # [a, b] are beyond the min_time, but [c] isn't. lru_hash.set("d", create_circuit_breaker("d")) assert_equal(2, lru_hash.size) - assert_equal ["c", "d"], lru_hash.values.map(&:name) + assert_equal(["c", "d"], lru_hash.values.map(&:name)) end private