Files
redis-go/cluster/com_test.go
2021-05-04 20:51:55 +08:00

38 lines
1.0 KiB
Go

package cluster
import (
"github.com/hdt3213/godis/redis/reply/asserts"
"testing"
)
func TestExec(t *testing.T) {
testCluster2 := MakeTestCluster([]string{"127.0.0.1:6379"})
for i := 0; i < 1000; i++ {
key := RandString(4)
value := RandString(4)
testCluster2.Exec(nil, toArgs("SET", key, value))
ret := testCluster2.Exec(nil, toArgs("GET", key))
asserts.AssertBulkReply(t, ret, value)
}
}
func TestRelay(t *testing.T) {
testCluster2 := MakeTestCluster([]string{"127.0.0.1:6379"})
key := RandString(4)
value := RandString(4)
ret := testCluster2.Relay("127.0.0.1:6379", nil, toArgs("SET", key, value))
asserts.AssertNotError(t, ret)
ret = testCluster2.Relay("127.0.0.1:6379", nil, toArgs("GET", key))
asserts.AssertBulkReply(t, ret, value)
}
func TestBroadcast(t *testing.T) {
testCluster2 := MakeTestCluster([]string{"127.0.0.1:6379"})
key := RandString(4)
value := RandString(4)
rets := testCluster2.Broadcast(nil, toArgs("SET", key, value))
for _, v := range rets {
asserts.AssertNotError(t, v)
}
}