Skip to content

Commit a4fb749

Browse files
author
Juuso Mäyränen
committed
Fix potential out of bounds index in test
1 parent 40c52e9 commit a4fb749

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

spec/inputs/redis_spec.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ def wait_events(conf, event_count)
2626
end
2727

2828
def process(conf, event_count)
29+
expect(event_count).to be > 0
2930
events = wait_events(conf, event_count)
3031
# due multiple workers we get events out-of-order in the output
3132
events.sort! { |a, b| a.get('sequence') <=> b.get('sequence') }
32-
expect(events[0].get('sequence')).to eq(0)
33-
expect(events[100].get('sequence')).to eq(100)
34-
expect(events[1000].get('sequence')).to eq(1000)
33+
[0, 100, 1000].each do |idx|
34+
idx = [idx, event_count - 1].min
35+
expect(events[idx].get('sequence')).to eq idx
36+
end
3537
end
3638

3739
# integration tests ---------------------

0 commit comments

Comments
 (0)