Skip to content

Commit

Permalink
fix: unary compatible middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
jayantxie committed Feb 13, 2025
1 parent f8c18e4 commit ea2e85e
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions thrift_streaming/grpcpb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,19 +238,13 @@ func TestGRPCPBServerMiddleware(t *testing.T) {
svr := RunGRPCPBServer(&GRPCPBServiceImpl{}, addr,
server.WithMiddleware(func(e endpoint.Endpoint) endpoint.Endpoint {
return func(ctx context.Context, req, resp interface{}) (err error) {
method, _ := kitexutil.GetMethod(ctx)
_, ok := req.(*streaming.Args)
isKitexPB, _ := metainfo.GetValue(ctx, "TEST_KITEX_PB")
if !ok && isKitexPB != "1" {
return fmt.Errorf("invalid request type: %T, method = %v", req, method)
}
if isKitexPB == "1" {
req.(*grpcpbservice.EchoPingPongArgs).Req.Message += "_mwReq"
if ok {
return e(ctx, req, resp)
}
req.(*grpcpbservice.EchoPingPongArgs).Req.Message += "_mwReq"
err = e(ctx, req, resp)
if isKitexPB == "1" {
resp.(*grpcpbservice.EchoPingPongResult).Success.Message += "_mwResp"
}
resp.(*grpcpbservice.EchoPingPongResult).Success.Message += "_mwResp"
return
}
}),
Expand Down Expand Up @@ -282,7 +276,7 @@ func TestGRPCPBServerMiddleware(t *testing.T) {
Message: "EchoPingPong",
})
test.Assert(t, err == nil)
test.Assert(t, resp.Message == "EchoPingPong_recv_send", resp.Message)
test.Assert(t, resp.Message == "EchoPingPong_mwReq_mwResp", resp.Message)
})

t.Run("client", func(t *testing.T) {
Expand Down

0 comments on commit ea2e85e

Please sign in to comment.