-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresp-get_test.go
41 lines (28 loc) · 972 Bytes
/
resp-get_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"testing"
)
func TestUnwrapRedisKey(t *testing.T) {
key := unwrapRedisKey([]byte{'*', '2', '\r', '\n', '$', '3', '\r', '\n', 'G', 'E', 'T', '\r', '\n', '$', '4', '\r', '\n', 'k', 'e', 'y', 't', '\r', '\n'})
if string(key) != "keyt" {
t.Errorf("Expected 'keyt'. Got '%s'", string(key))
}
}
func TestWrapRedisKey(t *testing.T) {
formattedKey := wrapRedisKey("keyt")
if formattedKey != "*2\r\n$3\r\nGET\r\n$4\r\nkeyt\r\n" {
t.Errorf("Expected '*2\r\n$3\r\nGET\r\n$4\r\nkeyt\r\n', got '%s'", formattedKey)
}
}
func TestUnwrapRedisValue(t *testing.T) {
value := unwrapRedisValue([]byte{'$', '6', '\r', '\n', 'v', 'a', 'l', 'u', 'e', 't', '\r', '\n'})
if string(value) != "valuet" {
t.Errorf("Expected 'valuet'. Got '%s'", string(value))
}
}
func TestWrapRedisValue(t *testing.T) {
returnVal := wrapRedisValue("valuet")
if returnVal != "$6\r\nvaluet\r\n" {
t.Errorf("Expected '$6\r\nvaluet\r\n'. Got '%s'", returnVal)
}
}