Skip to content

Commit 1f09bfa

Browse files
authored
Merge pull request #1136 from fatkodima/rpop-lpop-missing-key
Add tests for `lpop`/`rpop` with the missing key
2 parents 03b060f + cae39dd commit 1f09bfa

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/redis/commands/lists.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def rpushx(key, value)
9999
#
100100
# @param [String] key
101101
# @param [Integer] count number of elements to remove
102-
# @return [String, Array<String>] the values of the first elements
102+
# @return [nil, String, Array<String>] the values of the first elements
103103
def lpop(key, count = nil)
104104
command = [:lpop, key]
105105
command << Integer(count) if count
@@ -110,7 +110,7 @@ def lpop(key, count = nil)
110110
#
111111
# @param [String] key
112112
# @param [Integer] count number of elements to remove
113-
# @return [String, Array<String>] the values of the last elements
113+
# @return [nil, String, Array<String>] the values of the last elements
114114
def rpop(key, count = nil)
115115
command = [:rpop, key]
116116
command << Integer(count) if count

test/lint/lists.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ def test_lpop
140140
assert_equal 2, r.llen("foo")
141141
assert_equal "s1", r.lpop("foo")
142142
assert_equal 1, r.llen("foo")
143+
assert_nil r.lpop("nonexistent")
143144
end
144145

145146
def test_lpop_count
@@ -160,6 +161,7 @@ def test_rpop
160161
assert_equal 2, r.llen("foo")
161162
assert_equal "s2", r.rpop("foo")
162163
assert_equal 1, r.llen("foo")
164+
assert_nil r.rpop("nonexistent")
163165
end
164166

165167
def test_rpop_count

0 commit comments

Comments
 (0)