This commit is contained in:
wangchuxiao
2023-02-09 14:40:49 +08:00
parent 8c6c7ee21f
commit 414915eb3b
66 changed files with 424 additions and 1296 deletions
+9 -44
View File
@@ -3,7 +3,7 @@ package cache
import (
"Open_IM/pkg/common/constant"
pbChat "Open_IM/pkg/proto/msg"
server_api_params "Open_IM/pkg/proto/sdk_ws"
common "Open_IM/pkg/proto/sdk_ws"
"context"
"flag"
"fmt"
@@ -11,6 +11,8 @@ import (
"testing"
)
var DB RedisClient
func Test_SetTokenMapByUidPid(t *testing.T) {
m := make(map[string]int, 0)
m["test1"] = 1
@@ -35,7 +37,7 @@ func Test_GetKeyTTL(t *testing.T) {
ctx := context.Background()
key := flag.String("key", "key", "key value")
flag.Parse()
ttl, err := DB.RDB.TTL(ctx, *key).Result()
ttl, err := DB.GetClient().TTL(ctx, *key).Result()
assert.Nil(t, err)
fmt.Println(ttl)
}
@@ -43,7 +45,7 @@ func Test_HGetAll(t *testing.T) {
ctx := context.Background()
key := flag.String("key", "key", "key value")
flag.Parse()
ttl, err := DB.RDB.TTL(ctx, *key).Result()
ttl, err := DB.GetClient().TTL(ctx, *key).Result()
assert.Nil(t, err)
fmt.Println(ttl)
}
@@ -51,14 +53,14 @@ func Test_HGetAll(t *testing.T) {
func Test_NewSetMessageToCache(t *testing.T) {
var msg pbChat.MsgDataToMQ
m := make(map[string]bool)
var offlinePush server_api_params.OfflinePushInfo
var offlinePush common.OfflinePushInfo
offlinePush.Title = "3"
offlinePush.Ex = "34"
offlinePush.IOSPushSound = "+1"
offlinePush.IOSBadgeCount = true
m[constant.IsPersistent] = true
m[constant.IsHistory] = true
var data server_api_params.MsgData
var data common.MsgData
uid := "test_uid"
data.Seq = 11
data.ClientMsgID = "23jwhjsdf"
@@ -77,7 +79,7 @@ func Test_NewSetMessageToCache(t *testing.T) {
}
func Test_NewGetMessageListBySeq(t *testing.T) {
var msg pbChat.MsgDataToMQ
var data server_api_params.MsgData
var data common.MsgData
uid := "test_uid"
data.Seq = 11
data.ClientMsgID = "23jwhjsdf"
@@ -88,37 +90,7 @@ func Test_NewGetMessageListBySeq(t *testing.T) {
fmt.Println(seqMsg, failedSeqList)
}
func Test_SetUserGlobalMsgRecvOpt(t *testing.T) {
var opt int32
uid := "test_uid"
opt = 1
err := DB.SetUserGlobalMsgRecvOpt(uid, opt)
assert.Nil(t, err)
}
func Test_GetUserGlobalMsgRecvOpt(t *testing.T) {
uid := "test_uid"
opt, err := DB.GetUserGlobalMsgRecvOpt(uid)
assert.Nil(t, err)
fmt.Println("get opt", opt)
}
func Test_JudgeAccountEXISTS(t *testing.T) {
uid := "test_uid"
b, err := DB.JudgeAccountEXISTS(uid)
assert.Nil(t, err)
fmt.Println(b)
}
func Test_SetAccountCode(t *testing.T) {
uid := "test_uid"
code := 666666
err := DB.SetAccountCode(uid, code, 100)
assert.Nil(t, err)
}
func Test_GetAccountCode(t *testing.T) {
uid := "test_uid"
code, err := DB.GetAccountCode(uid)
assert.Nil(t, err)
fmt.Println(code)
}
func Test_SetFcmToken(t *testing.T) {
uid := "test_uid"
token := "dfnWBtOjSj-XIZnUvDlegv:APA91bG09XTtiXfpE6U7gUVMOhnKcUkNCv4WHn0UZr2clUi-tS1jEH-HiCEW8GIAhjLIGcfUJ6NIKteC023ZxDH7J0PJ5sTxoup3fHDUPLU7KgQoZS4tPyFqCbZ6bRB7esDPEnD1n_s0"
@@ -133,10 +105,3 @@ func Test_GetFcmToken(t *testing.T) {
assert.Nil(t, err)
fmt.Println("token is :", token)
}
//func Test_GetGroupMemberList(t *testing.T) {
// groupID := "3791742301"
// list, err := DB.GetGroupMemberIDListFromCache(groupID)
// assert.Nil(t, err)
// fmt.Println(list)
//}