@@ -73,7 +73,7 @@ func TestHashToRedisCmd(t *testing.T) {
73
73
}
74
74
75
75
testCases := []testCase {
76
- {key : "Paris" , value : map [string ]string {"country" : "France" , "weather" : "sunny" }, expected : []string {"HSET" , "Paris" , "country" , "France" , "weather" , "sunny" }},
76
+ {key : "Paris" , value : map [string ]string {"country" : "France" , "weather" : "sunny" , "poi" : "Tour Eiffel" }, expected : []string {"HSET" , "Paris" , "country" , "France" , "weather" , "sunny" , "poi" , "Tour Eiffel " }},
77
77
}
78
78
79
79
for _ , test := range testCases {
@@ -125,6 +125,26 @@ func TestRESPSerializer(t *testing.T) {
125
125
}
126
126
}
127
127
128
+
129
+ func TestRedisCmdSerializer (t * testing.T ) {
130
+ type testCase struct {
131
+ command []string
132
+ expected string
133
+ }
134
+
135
+ testCases := []testCase {
136
+ {command : []string {"SET" , "key name 1" , "key value 1" }, expected : "SET \" key name 1\" \" key value 1\" " },
137
+ {command : []string {"HSET" , "key1" , "key value 1" }, expected : "HSET key1 \" key value 1\" " },
138
+ }
139
+
140
+ for _ , test := range testCases {
141
+ s := RedisCmdSerializer (test .command )
142
+ if s != test .expected {
143
+ t .Errorf ("Failed serializing command to redis protocol: expected %s, got %s" , test .expected , s )
144
+ }
145
+ }
146
+ }
147
+
128
148
func TestParseKeyspaceInfo (t * testing.T ) {
129
149
keyspaceInfo := `# Keyspace
130
150
db0:keys=2,expires=1,avg_ttl=1009946407050
0 commit comments