-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmd_safe_test.go
46 lines (35 loc) · 1.16 KB
/
cmd_safe_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
package redisson
import (
"context"
. "github.com/smartystreets/goconvey/convey"
"testing"
)
func testSafeMGet(ctx context.Context, c Cmdable) []string {
var key, key1, key2, key3 = "key1:{1}", "key2", "key3", "key4:{1}"
So(slot(key), ShouldNotEqual, slot(key1))
So(slot(key1), ShouldNotEqual, slot(key2))
So(slot(key), ShouldEqual, slot(key3))
mSet := c.MSet(ctx, key, "hello1")
So(mSet.Err(), ShouldBeNil)
So(mSet.Val(), ShouldEqual, OK)
So(c.Get(ctx, key).Val(), ShouldEqual, "hello1")
mSet = c.MSet(ctx, key3, "hello4")
So(mSet.Err(), ShouldBeNil)
So(mSet.Val(), ShouldEqual, OK)
mSet = c.MSet(ctx, key2, "hello3")
So(mSet.Err(), ShouldBeNil)
So(mSet.Val(), ShouldEqual, OK)
mSet = c.MSet(ctx, key1, "hello2")
So(mSet.Err(), ShouldBeNil)
So(mSet.Val(), ShouldEqual, OK)
mGet := c.SafeMGet(ctx, key, key1, key2, key3, "_")
So(mGet.Err(), ShouldBeNil)
So(interfaceSliceEqual(mGet.Val(), []any{"hello1", "hello2", "hello3", "hello4", nil}), ShouldBeTrue)
return []string{key, key1}
}
func safeTestUnits() []TestUnit {
return []TestUnit{
{CommandMGet, testSafeMGet},
}
}
func TestClient_Safe(t *testing.T) { doClusterTestUnits(t, safeTestUnits) }