]>
git.saurik.com Git - redis.git/blob - tests/integration/redis-cli.tcl
191c6598b6833006851f2f0e48a0e88f45b5be0f
1 start_server
{tags
{"cli"}} {
4 set fd
[open [format "|src/redis-cli -p %d -n 9" [srv port
]] "r+"]
5 fconfigure $fd -buffering none
6 fconfigure $fd -blocking false
7 fconfigure $fd -translation binary
8 assert_equal
"redis> " [read_cli
$fd]
18 while {[string length
$buf] == 0} {
19 # wait some time and try again
26 proc write_cli
{fd buf
} {
31 proc run_command
{fd cmd
} {
33 set lines
[split [read_cli
$fd] "\n"]
34 assert_equal
"redis> " [lindex $lines end
]
35 join [lrange $lines 0 end-1
] "\n"
38 proc test_interactive_cli
{name code
} {
40 test
"Interactive CLI: $name" $code
44 test_interactive_cli
"INFO response should be printed raw" {
45 set lines
[split [run_command
$fd info] "\n"]
47 assert
[regexp {^
[a-z0-9_
]+:[a-z0-9_
]+} $line]
51 test_interactive_cli
"Status reply" {
52 assert_equal
"OK" [run_command
$fd "set key foo"]
55 test_interactive_cli
"Integer reply" {
56 assert_equal
"(integer) 1" [run_command
$fd "incr counter"]
59 test_interactive_cli
"Bulk reply" {
61 assert_equal
"\"foo\"" [run_command
$fd "get key"]
64 test_interactive_cli
"Multi-bulk reply" {
67 assert_equal
"1. \"foo\"\n2. \"bar\"" [run_command
$fd "lrange list 0 -1"]