mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 00:28:26 -05:00
Streams: add tests for XSTREAM command
This commit is contained in:
parent
ec511fa709
commit
5f3adbee33
@ -363,3 +363,42 @@ start_server {tags {"stream"} overrides {appendonly yes stream-node-max-entries
|
||||
assert {[r xlen mystream] == 90}
|
||||
}
|
||||
}
|
||||
|
||||
start_server {tags {"xstream command"}} {
|
||||
test {XSTREAM can CREATE an empty stream} {
|
||||
r XSTREAM CREATE mystream *
|
||||
assert {[dict get [r xinfo stream mystream] length] == 0}
|
||||
}
|
||||
|
||||
test {XSTREAM cannot CREATE on an busy stream} {
|
||||
catch {r XSTREAM CREATE mystream *} err
|
||||
set _ $err
|
||||
} {BUSY*}
|
||||
|
||||
test {XSTREAM can CREATE an empty stream with specific ID} {
|
||||
r del mystream
|
||||
r XSTREAM CREATE mystream "100-100"
|
||||
assert {[dict get [r xinfo stream mystream] length] == 0}
|
||||
assert {[dict get [r xinfo stream mystream] last-generated-id] == "100-100"}
|
||||
}
|
||||
|
||||
test {XSTREAM can SETID with $} {
|
||||
r XSTREAM SETID mystream $
|
||||
assert {[dict get [r xinfo stream mystream] last-generated-id] == "100-100"}
|
||||
}
|
||||
|
||||
test {XSTREAM can SETID with specific ID} {
|
||||
r XSTREAM SETID mystream "200-0"
|
||||
assert {[dict get [r xinfo stream mystream] last-generated-id] == "200-0"}
|
||||
}
|
||||
|
||||
test {XSTREAM cannot SETID with smaller ID} {
|
||||
catch {r XSTREAM SETID mystream "0-0"} err
|
||||
set _ $err
|
||||
} {ERR*smaller*}
|
||||
|
||||
test {XSTREAM cannot SETID on non-existent key} {
|
||||
catch {r XSTREAM SETID stream $} err
|
||||
set _ $err
|
||||
} {ERR no such key}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user