Add missing file

Former-commit-id: 97fd73692363e05b80e0c0e84b7b2b8fe7f760b8
This commit is contained in:
John Sully 2020-11-11 03:29:38 +00:00
parent 4f7ac9c11f
commit 2fdac516a6

View File

@ -0,0 +1,51 @@
start_server {tags {"nested_hash"}} {
test {Simple set/get} {
assert_equal [r keydb.nhset foo bar] 0
assert_equal bar [r keydb.nhget foo]
}
test {overwrite} {
r flushall
assert_equal [r keydb.nhset foo bar] 0
assert_equal [r keydb.nhset foo baz] 1
assert_equal [r keydb.nhget foo] baz
}
test {get simple string} {
r keydb.nhset foo bar
assert_equal [r keydb.nhget json foo] {"bar"}
assert_equal [r keydb.nhget foo] "bar"
}
test {get array} {
r keydb.nhset foo a b c d
assert_equal [r keydb.nhget json foo] {["a","b","c","d"]}
assert_equal [r keydb.nhget foo] {a b c d}
}
test {overwrite string with object} {
r keydb.nhset a.b.c val1
r keydb.nhset a.b val2
r keydb.nhset a.b.c.d val3
assert_equal [r keydb.nhget json a] {{"b" : {"c" : {"d" : "val3"}}}}
}
test {malformed nested key} {
assert_error *syntax* {r keydb.nhset a..b val1}
}
test {missing final selector key} {
assert_error *syntax* {r keydb.nhset a.b. val1}
}
test {expire nested hash} {
r keydb.nhset a.b.c val1
assert_equal [r expire a 100] 1
assert [expr [r ttl a] > 0]
}
test {expire subhash} {
r keydb.nhset a.b.c val1
assert_equal [r expire a.b 100] 0
}
}