quit.tcl 986 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. start_server {tags {"quit"}} {
  2. proc format_command {args} {
  3. set cmd "*[llength $args]\r\n"
  4. foreach a $args {
  5. append cmd "$[string length $a]\r\n$a\r\n"
  6. }
  7. set _ $cmd
  8. }
  9. test "QUIT returns OK" {
  10. reconnect
  11. assert_equal OK [r quit]
  12. assert_error * {r ping}
  13. }
  14. test "Pipelined commands after QUIT must not be executed" {
  15. reconnect
  16. r write [format_command quit]
  17. r write [format_command set foo bar]
  18. r flush
  19. assert_equal OK [r read]
  20. assert_error * {r read}
  21. reconnect
  22. assert_equal {} [r get foo]
  23. }
  24. test "Pipelined commands after QUIT that exceed read buffer size" {
  25. reconnect
  26. r write [format_command quit]
  27. r write [format_command set foo [string repeat "x" 1024]]
  28. r flush
  29. assert_equal OK [r read]
  30. assert_error * {r read}
  31. reconnect
  32. assert_equal {} [r get foo]
  33. }
  34. }