forked from DiceDB/dice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhget_test.go
49 lines (44 loc) · 1.22 KB
/
hget_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
42
43
44
45
46
47
48
49
package tests
import (
"testing"
"gotest.tools/v3/assert"
)
func TestHGET(t *testing.T) {
conn := getLocalConnection()
defer conn.Close()
defer fireCommand(conn, "DEL key_hGet key")
testCases := []TestCase{
{
commands: []string{"HGET", "HGET KEY", "HGET KEY FIELD ANOTHER_FIELD"},
expected: []interface{}{"ERR wrong number of arguments for 'hget' command",
"ERR wrong number of arguments for 'hget' command",
"ERR wrong number of arguments for 'hget' command"},
},
{
commands: []string{"HSET key_hGet field value", "HSET key_hGet field newvalue"},
expected: []interface{}{ONE, ZERO},
},
{
commands: []string{"HGET wrong_key_hGet field"},
expected: []interface{}{"(nil)"},
},
{
commands: []string{"HGET key_hGet wrong_field"},
expected: []interface{}{"(nil)"},
},
{
commands: []string{"HGET key_hGet field"},
expected: []interface{}{"newvalue"},
},
{
commands: []string{"SET key value", "HGET key field"},
expected: []interface{}{"OK", "WRONGTYPE Operation against a key holding the wrong kind of value"},
},
}
for _, tc := range testCases {
for i, cmd := range tc.commands {
result := fireCommand(conn, cmd)
assert.DeepEqual(t, tc.expected[i], result)
}
}
}