38 lines
784 B
Go
38 lines
784 B
Go
package cache
|
|
|
|
import (
|
|
"go_dreamfactory/pb"
|
|
"log"
|
|
"testing"
|
|
|
|
"github.com/liwei1dao/lego/sys/redis"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
var cache *Cache
|
|
|
|
func TestMain(m *testing.M) {
|
|
iredis, err := redis.NewSys(redis.Redis_Cluster_Addr([]string{"10.0.0.9:9001", "10.0.0.9:9002", "10.0.0.9:9003", "10.0.1.45:9004", "10.0.1.45:9005", "10.0.1.45:9006"}),
|
|
redis.SetRedis_Cluster_Password(""), redis.SetRedisType(redis.Redis_Cluster))
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
cache = &Cache{
|
|
redis: iredis,
|
|
}
|
|
defer m.Run()
|
|
}
|
|
|
|
func TestUpdateUser(t *testing.T) {
|
|
user := &pb.Cache_UserData{
|
|
SessionId: "1",
|
|
GatewayServiceId: "work",
|
|
UserData: &pb.DB_UserData{
|
|
UserId: 1,
|
|
Account: "aaa",
|
|
},
|
|
}
|
|
err := cache.User_UpdateUser(user)
|
|
require.Nil(t, err)
|
|
}
|