Skip to content

Commit

Permalink
Make sure ensure doesn't run if test is skipped
Browse files Browse the repository at this point in the history
  • Loading branch information
wcmonty committed Dec 4, 2022
1 parent 4321159 commit d7926fe
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions test/lint/streams.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,21 @@ def test_xtrim_with_approximate_option
def test_xtrim_with_limit_option
omit_version('6.2.0')

original = redis.config(:get, 'stream-node-max-entries')['stream-node-max-entries']
redis.config(:set, 'stream-node-max-entries', 1)

redis.xadd('s1', { f: 'v1' })
redis.xadd('s1', { f: 'v2' })
redis.xadd('s1', { f: 'v3' })
redis.xadd('s1', { f: 'v4' })

assert_equal 1, redis.xtrim('s1', 0, approximate: true, limit: 1)
error = assert_raises(Redis::CommandError) { redis.xtrim('s1', 0, limit: 1) }
assert_equal "ERR syntax error, LIMIT cannot be used without the special ~ option", error.message
ensure
redis.config(:set, 'stream-node-max-entries', original)
begin
original = redis.config(:get, 'stream-node-max-entries')['stream-node-max-entries']
redis.config(:set, 'stream-node-max-entries', 1)

redis.xadd('s1', { f: 'v1' })
redis.xadd('s1', { f: 'v2' })
redis.xadd('s1', { f: 'v3' })
redis.xadd('s1', { f: 'v4' })

assert_equal 1, redis.xtrim('s1', 0, approximate: true, limit: 1)
error = assert_raises(Redis::CommandError) { redis.xtrim('s1', 0, limit: 1) }
assert_equal "ERR syntax error, LIMIT cannot be used without the special ~ option", error.message
ensure
redis.config(:set, 'stream-node-max-entries', original)
end
end

def test_xtrim_with_maxlen_strategy
Expand Down

0 comments on commit d7926fe

Please sign in to comment.