2
0

infotest.tcl 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. set testmodule [file normalize tests/modules/infotest.so]
  2. # Return value for INFO property
  3. proc field {info property} {
  4. if {[regexp "\r\n$property:(.*?)\r\n" $info _ value]} {
  5. set _ $value
  6. }
  7. }
  8. start_server {tags {"modules"}} {
  9. r module load $testmodule log-key 0
  10. test {module info all} {
  11. set info [r info all]
  12. # info all does not contain modules
  13. assert { ![string match "*Spanish*" $info] }
  14. assert { ![string match "*infotest_*" $info] }
  15. assert { [string match "*used_memory*" $info] }
  16. }
  17. test {module info everything} {
  18. set info [r info everything]
  19. # info everything contains all default sections, but not ones for crash report
  20. assert { [string match "*infotest_global*" $info] }
  21. assert { [string match "*Spanish*" $info] }
  22. assert { [string match "*Italian*" $info] }
  23. assert { [string match "*used_memory*" $info] }
  24. assert { ![string match "*Klingon*" $info] }
  25. field $info infotest_dos
  26. } {2}
  27. test {module info modules} {
  28. set info [r info modules]
  29. # info all does not contain modules
  30. assert { [string match "*Spanish*" $info] }
  31. assert { [string match "*infotest_global*" $info] }
  32. assert { ![string match "*used_memory*" $info] }
  33. }
  34. test {module info one module} {
  35. set info [r info INFOTEST]
  36. # info all does not contain modules
  37. assert { [string match "*Spanish*" $info] }
  38. assert { ![string match "*used_memory*" $info] }
  39. field $info infotest_global
  40. } {-2}
  41. test {module info one section} {
  42. set info [r info INFOTEST_SPANISH]
  43. assert { ![string match "*used_memory*" $info] }
  44. assert { ![string match "*Italian*" $info] }
  45. assert { ![string match "*infotest_global*" $info] }
  46. field $info infotest_uno
  47. } {one}
  48. test {module info dict} {
  49. set info [r info infotest_keyspace]
  50. set keyspace [field $info infotest_db0]
  51. set keys [scan [regexp -inline {keys\=([\d]*)} $keyspace] keys=%d]
  52. } {3}
  53. # TODO: test crash report.
  54. }