@@ -8,23 +8,24 @@ import (
88)
99
1010func TestMiniredis_cmdInfo (t * testing.T ) {
11- s , c := runWithClient (t )
12-
1311 t .Run ("Invalid section name" , func (t * testing.T ) {
12+ _ , c := runWithClient (t )
1413 mustDo (t , c ,
1514 "INFO" , "invalid_or_unsupported_section_name" ,
1615 proto .Error ("section (invalid_or_unsupported_section_name) is not supported" ),
1716 )
1817 })
1918
2019 t .Run ("No section name in args" , func (t * testing.T ) {
20+ _ , c := runWithClient (t )
2121 mustDo (t , c ,
2222 "INFO" ,
23- proto .String ("# Clients\n connected_clients:1\r \n " ),
23+ proto .String ("# Clients\n connected_clients:1\r \n # Stats \n total_connections_received:1 \r \n total_commands_processed:1 \r \n " ),
2424 )
2525 })
2626
27- t .Run ("Success" , func (t * testing.T ) {
27+ t .Run ("Success for clients section" , func (t * testing.T ) {
28+ s , c := runWithClient (t )
2829 mustDo (t , c ,
2930 "INFO" , "clients" ,
3031 proto .String ("# Clients\n connected_clients:1\r \n " ),
@@ -48,4 +49,30 @@ func TestMiniredis_cmdInfo(t *testing.T) {
4849 proto .String ("# Clients\n connected_clients:2\r \n " ),
4950 )
5051 })
52+
53+ t .Run ("Success for stats section" , func (t * testing.T ) {
54+ s , c := runWithClient (t )
55+ mustDo (t , c ,
56+ "INFO" , "stats" ,
57+ proto .String ("# Stats\n total_connections_received:1\r \n total_commands_processed:1\r \n " ),
58+ )
59+
60+ c2 , err := proto .Dial (s .Addr ())
61+ ok (t , err )
62+ mustDo (t , c2 ,
63+ "INFO" , "stats" ,
64+ proto .String ("# Stats\n total_connections_received:2\r \n total_commands_processed:2\r \n " ),
65+ )
66+ c2 .Close ()
67+
68+ time .Sleep (10 * time .Millisecond )
69+
70+ c3 , err := proto .Dial (s .Addr ())
71+ ok (t , err )
72+ defer c3 .Close ()
73+ mustDo (t , c3 ,
74+ "INFO" , "stats" ,
75+ proto .String ("# Stats\n total_connections_received:3\r \n total_commands_processed:3\r \n " ),
76+ )
77+ })
5178}
0 commit comments