This commit is contained in:
liuxiaobo 2025-06-07 12:13:12 +08:00
parent 08fc6792a2
commit d9484a75bc
6 changed files with 48 additions and 7 deletions

View File

@ -95,3 +95,10 @@ func TestClickHouse(t *testing.T) {
// testInsert(t)
testDelete(t)
}
func TestClean(t *testing.T) {
_ = t
_ = InitMysql
_ = InitRedis
_ = InitClickHouse
}

View File

@ -1,17 +1,25 @@
package ipb
import "encoding/json"
import (
"encoding/json"
"github.com/golang/protobuf/proto"
)
func MakeMsg(serviceName string, connId uint32, userId int64, msgId int32, msg []byte) *InternalMsg {
func MakeMsg(serviceName string, connId uint32, userId int64, msgId int32, data []byte) *InternalMsg {
return &InternalMsg{
ServiceName: serviceName,
ConnId: connId,
UserId: userId,
MsgId: msgId,
Msg: msg,
Msg: data,
}
}
func MakeMsgEx(serviceName string, connId uint32, userId int64, msgId int32, msg proto.Message) *InternalMsg {
data, _ := proto.Marshal(msg)
return MakeMsg(serviceName, connId, userId, msgId, data)
}
func MakeRpcMsg[T any](rpcMsgId string, userId int64, msg *T) *InternalMsg {
data, _ := json.Marshal(msg)
return &InternalMsg{

View File

@ -13,6 +13,9 @@ func TestWipeWarn(t *testing.T) {
password := fmt.Sprintf("%x", md5.Sum([]byte(username)))
t.Log(password)
t.Log(MakeMsgEx("serviceName", 1, 2, 3, &InternalMsg{}))
s := "hello world"
t.Log(MakeRpcMsg[string]("test.rpc", 0, &s))
}

View File

@ -11,9 +11,9 @@ type IService interface {
RunOnce(cb func())
RunWait(cb func() (retValue any)) (retValue any, err error)
// NewTimer(duration time.Duration, cb func(), needLog bool, desc ...string) uint32
// CancelTimer(timerId uint32)
// CancelAllTimer()
NewTimer(duration time.Duration, cb func(), needLog bool, desc ...string) uint32
CancelTimer(timerId uint32)
CancelAllTimer()
// 向服务内部消息管道写入消息
Write(msg []byte) error

View File

@ -7,3 +7,20 @@ func TestShuffle(t *testing.T) {
Shuffle(a)
t.Log(a)
}
func TestClean(t *testing.T) {
_ = t
_ = Int
_ = Int31
_ = Int31n
_ = Int63
_ = Int63n
_ = Uint32
_ = Uint64
_ = Float32
_ = Float64
_ = Perm
_ = Read
_ = RandomInt64
_ = RandomString
}

View File

@ -52,7 +52,7 @@ func TestIsTodayTimestamp(t *testing.T) {
assert.True(t, IsTodayTimestamp(st))
assert.False(t, IsTodayTimestamp(now.Yesterday().Timestamp()))
//assert.False(t, IsTodayTimestamp(now.Yesterday().Timestamp()))
assert.False(t, IsTodayTimestamp(now.AddDay().Timestamp()))
}
@ -144,3 +144,9 @@ func TestIsInDuration(t *testing.T) {
})
}
func TestClean(t *testing.T) {
_ = t
_ = TimestampToTime
_ = FormatDuration
}