summaryrefslogtreecommitdiff
path: root/tests/unit/moduleapi/infotest.tcl
diff options
context:
space:
mode:
authorGuy Korland <gkorland@gmail.com>2019-10-20 09:59:23 +0300
committerGuy Korland <gkorland@gmail.com>2019-10-20 09:59:23 +0300
commit1ac30300f027c334aa044a6f579562e52f43f26b (patch)
treed36b9c30601f7460f643842e2dee5aeb27dd7903 /tests/unit/moduleapi/infotest.tcl
parentc1455dc06025259dc662144f3ca668d88789f9c0 (diff)
parent673c9d702962a5618650108eaf4c5f38bcafe164 (diff)
downloadredis-1ac30300f027c334aa044a6f579562e52f43f26b.tar.gz
Merge branch 'unstable' of github.com:antirez/redis into unstable
Diffstat (limited to 'tests/unit/moduleapi/infotest.tcl')
-rw-r--r--tests/unit/moduleapi/infotest.tcl63
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/unit/moduleapi/infotest.tcl b/tests/unit/moduleapi/infotest.tcl
new file mode 100644
index 000000000..659ee79d7
--- /dev/null
+++ b/tests/unit/moduleapi/infotest.tcl
@@ -0,0 +1,63 @@
+set testmodule [file normalize tests/modules/infotest.so]
+
+# Return value for INFO property
+proc field {info property} {
+ if {[regexp "\r\n$property:(.*?)\r\n" $info _ value]} {
+ set _ $value
+ }
+}
+
+start_server {tags {"modules"}} {
+ r module load $testmodule log-key 0
+
+ test {module info all} {
+ set info [r info all]
+ # info all does not contain modules
+ assert { ![string match "*Spanish*" $info] }
+ assert { ![string match "*infotest_*" $info] }
+ assert { [string match "*used_memory*" $info] }
+ }
+
+ test {module info everything} {
+ set info [r info everything]
+ # info everything contains all default sections, but not ones for crash report
+ assert { [string match "*infotest_global*" $info] }
+ assert { [string match "*Spanish*" $info] }
+ assert { [string match "*Italian*" $info] }
+ assert { [string match "*used_memory*" $info] }
+ assert { ![string match "*Klingon*" $info] }
+ field $info infotest_dos
+ } {2}
+
+ test {module info modules} {
+ set info [r info modules]
+ # info all does not contain modules
+ assert { [string match "*Spanish*" $info] }
+ assert { [string match "*infotest_global*" $info] }
+ assert { ![string match "*used_memory*" $info] }
+ }
+
+ test {module info one module} {
+ set info [r info INFOTEST]
+ # info all does not contain modules
+ assert { [string match "*Spanish*" $info] }
+ assert { ![string match "*used_memory*" $info] }
+ field $info infotest_global
+ } {-2}
+
+ test {module info one section} {
+ set info [r info INFOTEST_SPANISH]
+ assert { ![string match "*used_memory*" $info] }
+ assert { ![string match "*Italian*" $info] }
+ assert { ![string match "*infotest_global*" $info] }
+ field $info infotest_uno
+ } {one}
+
+ test {module info dict} {
+ set info [r info infotest_keyspace]
+ set keyspace [field $info infotest_db0]
+ set keys [scan [regexp -inline {keys\=([\d]*)} $keyspace] keys=%d]
+ } {3}
+
+ # TODO: test crash report.
+}