修正
This commit is contained in:
parent
08fc6792a2
commit
d9484a75bc
@ -95,3 +95,10 @@ func TestClickHouse(t *testing.T) {
|
|||||||
// testInsert(t)
|
// testInsert(t)
|
||||||
testDelete(t)
|
testDelete(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestClean(t *testing.T) {
|
||||||
|
_ = t
|
||||||
|
_ = InitMysql
|
||||||
|
_ = InitRedis
|
||||||
|
_ = InitClickHouse
|
||||||
|
}
|
||||||
|
@ -1,17 +1,25 @@
|
|||||||
package ipb
|
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{
|
return &InternalMsg{
|
||||||
ServiceName: serviceName,
|
ServiceName: serviceName,
|
||||||
ConnId: connId,
|
ConnId: connId,
|
||||||
UserId: userId,
|
UserId: userId,
|
||||||
MsgId: msgId,
|
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 {
|
func MakeRpcMsg[T any](rpcMsgId string, userId int64, msg *T) *InternalMsg {
|
||||||
data, _ := json.Marshal(msg)
|
data, _ := json.Marshal(msg)
|
||||||
return &InternalMsg{
|
return &InternalMsg{
|
||||||
|
@ -13,6 +13,9 @@ func TestWipeWarn(t *testing.T) {
|
|||||||
|
|
||||||
password := fmt.Sprintf("%x", md5.Sum([]byte(username)))
|
password := fmt.Sprintf("%x", md5.Sum([]byte(username)))
|
||||||
t.Log(password)
|
t.Log(password)
|
||||||
|
|
||||||
|
t.Log(MakeMsgEx("serviceName", 1, 2, 3, &InternalMsg{}))
|
||||||
|
|
||||||
s := "hello world"
|
s := "hello world"
|
||||||
t.Log(MakeRpcMsg[string]("test.rpc", 0, &s))
|
t.Log(MakeRpcMsg[string]("test.rpc", 0, &s))
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,9 @@ type IService interface {
|
|||||||
RunOnce(cb func())
|
RunOnce(cb func())
|
||||||
RunWait(cb func() (retValue any)) (retValue any, err error)
|
RunWait(cb func() (retValue any)) (retValue any, err error)
|
||||||
|
|
||||||
// NewTimer(duration time.Duration, cb func(), needLog bool, desc ...string) uint32
|
NewTimer(duration time.Duration, cb func(), needLog bool, desc ...string) uint32
|
||||||
// CancelTimer(timerId uint32)
|
CancelTimer(timerId uint32)
|
||||||
// CancelAllTimer()
|
CancelAllTimer()
|
||||||
|
|
||||||
// 向服务内部消息管道写入消息
|
// 向服务内部消息管道写入消息
|
||||||
Write(msg []byte) error
|
Write(msg []byte) error
|
||||||
|
@ -7,3 +7,20 @@ func TestShuffle(t *testing.T) {
|
|||||||
Shuffle(a)
|
Shuffle(a)
|
||||||
t.Log(a)
|
t.Log(a)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestClean(t *testing.T) {
|
||||||
|
_ = t
|
||||||
|
_ = Int
|
||||||
|
_ = Int31
|
||||||
|
_ = Int31n
|
||||||
|
_ = Int63
|
||||||
|
_ = Int63n
|
||||||
|
_ = Uint32
|
||||||
|
_ = Uint64
|
||||||
|
_ = Float32
|
||||||
|
_ = Float64
|
||||||
|
_ = Perm
|
||||||
|
_ = Read
|
||||||
|
_ = RandomInt64
|
||||||
|
_ = RandomString
|
||||||
|
}
|
||||||
|
@ -52,7 +52,7 @@ func TestIsTodayTimestamp(t *testing.T) {
|
|||||||
|
|
||||||
assert.True(t, IsTodayTimestamp(st))
|
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()))
|
assert.False(t, IsTodayTimestamp(now.AddDay().Timestamp()))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,3 +144,9 @@ func TestIsInDuration(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestClean(t *testing.T) {
|
||||||
|
_ = t
|
||||||
|
_ = TimestampToTime
|
||||||
|
_ = FormatDuration
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user