From 99aadd9fd6444e1bb5cc62ce63915261de4cf736 Mon Sep 17 00:00:00 2001 From: Watson Date: Fri, 18 Oct 2024 12:10:30 +0900 Subject: [PATCH] tests: use never instead of dont_allow (#4671) Backported from a2b935ae2bc4b4d43e5adddbec01092ea4228b9e. Signed-off-by: Daijiro Fukuda --- If it use the object applied dont_allow in the other test through ObjectSpace.each_object, it will cause the error. To relax object constraints, this patch will use never instead. Signed-off-by: Shizuo Fujita --- test/plugin/out_forward/test_socket_cache.rb | 6 +++--- test/test_event_router.rb | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/plugin/out_forward/test_socket_cache.rb b/test/plugin/out_forward/test_socket_cache.rb index f7dec5a0f1..1d584d6b4e 100644 --- a/test/plugin/out_forward/test_socket_cache.rb +++ b/test/plugin/out_forward/test_socket_cache.rb @@ -17,7 +17,7 @@ class SocketCacheTest < Test::Unit::TestCase assert_equal(socket, c.checkout_or('key') { socket }) c.checkin(socket) - sock = dont_allow(mock!).open + sock = mock!.open.never.subject assert_equal(socket, c.checkout_or('key') { sock.open }) end @@ -130,7 +130,7 @@ def teardown c = Fluent::Plugin::ForwardOutput::SocketCache.new(10, $log) sock = mock!.close { 'closed' }.subject - sock2 = dont_allow(mock!).close + sock2 = mock!.close.never.subject stub(sock).inspect stub(sock2).inspect @@ -154,7 +154,7 @@ def teardown Timecop.freeze(Time.parse('2016-04-13 14:00:00 +0900')) c = Fluent::Plugin::ForwardOutput::SocketCache.new(10, $log) - sock = dont_allow(mock!).close + sock = mock!.close.never.subject stub(sock).inspect c.checkout_or('key') { sock } diff --git a/test/test_event_router.rb b/test/test_event_router.rb index 3601ddf10f..fda89db230 100644 --- a/test/test_event_router.rb +++ b/test/test_event_router.rb @@ -175,7 +175,7 @@ def event_router test "don't call default collector when tag matched" do event_router.add_rule('test', output) assert_rr do - dont_allow(default_collector).emit_events('test', is_a(OneEventStream)) + mock(default_collector).emit_events('test', is_a(OneEventStream)).never event_router.emit('test', Engine.now, 'k' => 'v') end # check emit handler doesn't catch rr error @@ -201,7 +201,7 @@ def filter_stream(_tag, es); end event_router.add_rule('test', filter) assert_rr do - dont_allow(filter).filter_stream('test', is_a(OneEventStream)) { events } + mock(filter).filter_stream('test', is_a(OneEventStream)).never event_router.emit('foo', Engine.now, 'k' => 'v') end end