-
Notifications
You must be signed in to change notification settings - Fork 1
/
hash_test.go
49 lines (46 loc) · 1.14 KB
/
hash_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 red
import (
"context"
"github.com/stretchr/testify/assert"
"testing"
)
func TestHdel(t *testing.T) {
for _, client := range Connecters {
redisHdel(t, client)
}
}
func redisHdel(t *testing.T, client Connecter) {
func() struct{} {
// -------------
ctx := context.TODO()
key := "hdel"
_, err := DEL{Key: key}.Do(ctx, client) ; assert.NoError(t, err)
{
_, err = client.DoIntegerReplyWithoutNil(ctx, []string{"HSET", key, "name", "goclub"})
assert.NoError(t, err)
delTotal, err := HDEL{
Key: key,
Field: []string{"name"},
}.Do(ctx, client) ; assert.NoError(t, err)
assert.Equal(t, delTotal, uint64(1))
}
{
delTotal, err := HDEL{
Key: key,
Field: []string{"name"},
}.Do(ctx, client) ; assert.NoError(t, err)
assert.Equal(t, delTotal, uint64(0))
}
{
_, err = client.DoIntegerReplyWithoutNil(ctx, []string{"HSET", key, "name", "goclub", "age", "18"})
assert.NoError(t, err)
delTotal, err := HDEL{
Key: key,
Field: []string{"name", "age"},
}.Do(ctx, client) ; assert.NoError(t, err)
assert.Equal(t, delTotal, uint64(2))
}
// -------------
return struct{}{}
}()
}