mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Add tests for empty fetch
This commit is contained in:
parent
cdfcf555af
commit
5b5c37eaf7
1 changed files with 24 additions and 1 deletions
|
@ -30,20 +30,43 @@ module CacheInstrumentationBehavior
|
||||||
|
|
||||||
assert_equal %w[ cache_read_multi.active_support ], events.map(&:name)
|
assert_equal %w[ cache_read_multi.active_support ], events.map(&:name)
|
||||||
assert_equal :fetch_multi, events[0].payload[:super_operation]
|
assert_equal :fetch_multi, events[0].payload[:super_operation]
|
||||||
|
assert_equal ["a", "b"], events[0].payload[:key]
|
||||||
assert_equal ["b"], events[0].payload[:hits]
|
assert_equal ["b"], events[0].payload[:hits]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_instrumentation_empty_fetch_multi
|
||||||
|
events = with_instrumentation "read_multi" do
|
||||||
|
@cache.fetch_multi() { |key| key * 2 }
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_equal %w[ cache_read_multi.active_support ], events.map(&:name)
|
||||||
|
assert_equal :fetch_multi, events[0].payload[:super_operation]
|
||||||
|
assert_equal [], events[0].payload[:key]
|
||||||
|
assert_equal [], events[0].payload[:hits]
|
||||||
|
end
|
||||||
|
|
||||||
def test_read_multi_instrumentation
|
def test_read_multi_instrumentation
|
||||||
@cache.write("b", "bb")
|
@cache.write("b", "bb")
|
||||||
|
|
||||||
events = with_instrumentation "read_multi" do
|
events = with_instrumentation "read_multi" do
|
||||||
@cache.read_multi("a", "b") { |key| key * 2 }
|
@cache.read_multi("a", "b")
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal %w[ cache_read_multi.active_support ], events.map(&:name)
|
assert_equal %w[ cache_read_multi.active_support ], events.map(&:name)
|
||||||
|
assert_equal ["a", "b"], events[0].payload[:key]
|
||||||
assert_equal ["b"], events[0].payload[:hits]
|
assert_equal ["b"], events[0].payload[:hits]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_empty_read_multi_instrumentation
|
||||||
|
events = with_instrumentation "read_multi" do
|
||||||
|
@cache.read_multi()
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_equal %w[ cache_read_multi.active_support ], events.map(&:name)
|
||||||
|
assert_equal [], events[0].payload[:key]
|
||||||
|
assert_equal [], events[0].payload[:hits]
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def with_instrumentation(method)
|
def with_instrumentation(method)
|
||||||
event_name = "cache_#{method}.active_support"
|
event_name = "cache_#{method}.active_support"
|
||||||
|
|
Loading…
Reference in a new issue