Skip to content

Commit

Permalink
tests: use never instead of dont_allow (#4671)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Watson1978 authored Oct 18, 2024
1 parent aaa62c1 commit a2b935a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions test/plugin/out_forward/test_socket_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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 }

Expand Down
4 changes: 2 additions & 2 deletions test/test_event_router.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit a2b935a

Please sign in to comment.