redict/tests/unit/moduleapi/zset.tcl
Viktor Söderqvist aea6e71ef8
RM_ZsetRem: Delete key if empty (#8453)
Without this fix, RM_ZsetRem can leave empty sorted sets which are
not allowed to exist.

Removing from a sorted set while iterating seems to work (while
inserting causes failed assetions). RM_ZsetRangeEndReached is
modified to return 1 if the key doesn't exist, to terminate
iteration when the last element has been removed.
2021-02-05 19:54:01 +02:00

17 lines
477 B
Tcl

set testmodule [file normalize tests/modules/zset.so]
start_server {tags {"modules"}} {
r module load $testmodule
test {Module zset rem} {
r del k
r zadd k 100 hello 200 world
assert_equal 1 [r zset.rem k hello]
assert_equal 0 [r zset.rem k hello]
assert_equal 1 [r exists k]
# Check that removing the last element deletes the key
assert_equal 1 [r zset.rem k world]
assert_equal 0 [r exists k]
}
}