|
|
@@ -4,7 +4,13 @@ import ( |
|
|
|
"context" |
|
|
|
"fmt" |
|
|
|
md3 "gim/internal/logic/domain/message/md" |
|
|
|
"gim/pkg/pb" |
|
|
|
"gim/pkg/util" |
|
|
|
"google.golang.org/grpc/metadata" |
|
|
|
"google.golang.org/protobuf/proto" |
|
|
|
"strconv" |
|
|
|
"testing" |
|
|
|
"time" |
|
|
|
|
|
|
|
jsoniter "github.com/json-iterator/go" |
|
|
|
) |
|
|
@@ -55,3 +61,35 @@ func Test_CommAddPush(t *testing.T) { |
|
|
|
Times: "sadff", |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
func Test_SendToUser(t *testing.T) { |
|
|
|
buf, _ := proto.Marshal(&pb.Text{ |
|
|
|
Text: "hello world!", |
|
|
|
}) |
|
|
|
MessageService.SendToUser(getCtx(), |
|
|
|
&pb.Sender{ |
|
|
|
SenderType: pb.SenderType_ST_USER, |
|
|
|
SenderId: 2, |
|
|
|
}, |
|
|
|
21, |
|
|
|
&pb.SendMessageReq{ |
|
|
|
ReceiverType: pb.ReceiverType_RT_USER, |
|
|
|
ReceiverId: 21, |
|
|
|
ToUserIds: nil, |
|
|
|
MessageType: pb.MessageType_MT_TEXT, |
|
|
|
MessageContent: buf, |
|
|
|
SendTime: util.UnixMilliTime(time.Now()), |
|
|
|
IsPersist: true, |
|
|
|
}, |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
|
|
func getCtx() context.Context { |
|
|
|
token := "ICXKTELAGMMJYXITSIOUNXFHYMTCWJHMJCIRZLPX" |
|
|
|
return metadata.NewOutgoingContext(context.TODO(), metadata.Pairs( |
|
|
|
"user_id", "2", |
|
|
|
"device_id", "5", |
|
|
|
"token", token, |
|
|
|
"master_id", "123456", |
|
|
|
"request_id", strconv.FormatInt(time.Now().UnixNano(), 10))) |
|
|
|
} |