forked from DiceDB/dice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdel_test.go
48 lines (42 loc) · 1.09 KB
/
del_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
package tests
import (
"testing"
"gotest.tools/v3/assert"
)
func TestDel(t *testing.T) {
conn := getLocalConnection()
defer conn.Close()
testCases := []struct {
name string
commands []string
expected []interface{}
}{
{
name: "DEL with set key",
commands: []string{"SET k1 v1", "DEL k1", "GET k1"},
expected: []interface{}{"OK", int64(1), "(nil)"},
},
{
name: "DEL with multiple keys",
commands: []string{"SET k1 v1", "SET k2 v2", "DEL k1 k2", "GET k1", "GET k2"},
expected: []interface{}{"OK", "OK", int64(2), "(nil)", "(nil)"},
},
{
name: "DEL with key not set",
commands: []string{"GET k3", "DEL k3"},
expected: []interface{}{"(nil)", int64(0)},
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
// deleteTestKeys([]string{"k1", "k2", "k3"}, store)
fireCommand(conn, "DEL k1")
fireCommand(conn, "DEL k2")
fireCommand(conn, "DEL k3")
for i, cmd := range tc.commands {
result := fireCommand(conn, cmd)
assert.Equal(t, tc.expected[i], result, "Value mismatch for cmd %s", cmd)
}
})
}
}