feat 历史记录

This commit is contained in:
2026-01-14 18:15:36 +08:00
parent 313a93702e
commit 636008b97d
16 changed files with 58 additions and 66 deletions

View File

@@ -5,7 +5,7 @@ import (
"context"
"fmt"
"git.hlsq.asia/mmorpg/service-common/db/redis"
"git.hlsq.asia/mmorpg/service-common/net/grpc/service"
"git.hlsq.asia/mmorpg/service-common/net/grpc/grpc_client"
"git.hlsq.asia/mmorpg/service-common/net/http/http_resp"
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb/mocks"
@@ -50,10 +50,10 @@ func (ts *LoginTestSuite) TestLogin() {
})
ts.Run("UserNewClientLB Failed", func() {
monkey.Patch(service.UserNewClientLB, func() (grpc_pb.UserClient, error) {
monkey.Patch(grpc_client.UserNewClientLB, func() (grpc_pb.UserClient, error) {
return nil, assert.AnError
})
defer monkey.Unpatch(service.UserNewClientLB)
defer monkey.Unpatch(grpc_client.UserNewClientLB)
w, c := utils.CreateTestContext("POST", "/", &LoginReq{
Phone: "13800000000",
@@ -68,13 +68,13 @@ func (ts *LoginTestSuite) TestLogin() {
defer ctrl.Finish()
client := mocks.NewMockUserClient(ctrl)
client.EXPECT().
Login(gomock.Any(), gomock.Any()).
PhoneLogin(gomock.Any(), gomock.Any()).
Return(nil, fmt.Errorf("gRPC failed"))
monkey.Patch(service.UserNewClientLB, func() (grpc_pb.UserClient, error) {
monkey.Patch(grpc_client.UserNewClientLB, func() (grpc_pb.UserClient, error) {
return client, nil
})
defer monkey.Unpatch(service.UserNewClientLB)
defer monkey.Unpatch(grpc_client.UserNewClientLB)
w, c := utils.CreateTestContext("POST", "/", &LoginReq{
Phone: "13800000000",
@@ -89,13 +89,13 @@ func (ts *LoginTestSuite) TestLogin() {
defer ctrl.Finish()
client := mocks.NewMockUserClient(ctrl)
client.EXPECT().
Login(gomock.Any(), gomock.Any()).
Return(&grpc_pb.LoginResp{USN: "1", Name: "hh"}, nil)
PhoneLogin(gomock.Any(), gomock.Any()).
Return(&grpc_pb.PhoneLoginResp{USN: "1", Name: "hh"}, nil)
monkey.Patch(service.UserNewClientLB, func() (grpc_pb.UserClient, error) {
monkey.Patch(grpc_client.UserNewClientLB, func() (grpc_pb.UserClient, error) {
return client, nil
})
defer monkey.Unpatch(service.UserNewClientLB)
defer monkey.Unpatch(grpc_client.UserNewClientLB)
w, c := utils.CreateTestContext("POST", "/", &LoginReq{
Phone: "13800000000",