Copilot commented on code in PR #3655:
URL: https://github.com/apache/dubbo-go/pull/3655#discussion_r3776117433


##########
protocol/triple/triple_protocol/triple_ext_test.go:
##########
@@ -710,6 +710,44 @@ func TestContextError(t *testing.T) {
        assert.False(t, triple.IsWireError(err))
 }
 
+func TestBizErrorCodePreservedAcrossProtocols(t *testing.T) {
+       t.Parallel()
+
+       handler := triple.NewUnaryHandler(
+               "/connect.ping.v1.PingService/Ping",
+               func() any { return new(pingv1.PingRequest) },
+               func(ctx context.Context, req *triple.Request) 
(*triple.Response, error) {
+                       return nil, triple.NewError(triple.CodeBizError, 
errors.New(errorMessage))
+               },
+       )
+       assertBizError := func(t *testing.T, server *httptest.Server, opts 
...triple.ClientOption) { //nolint:thelper
+               client := pingv1connect.NewPingServiceClient(server.Client(), 
server.URL, opts...)
+               request := triple.NewRequest(&pingv1.PingRequest{Number: 42})
+               response := triple.NewResponse(&pingv1.PingResponse{})
+               err := client.Ping(context.Background(), request, response)
+               assert.NotNil(t, err)
+               var tripleErr *triple.Error
+               assert.True(t, errors.As(err, &tripleErr))
+               assert.Equal(t, tripleErr.Code(), triple.CodeBizError)
+       }

Review Comment:
   Local helper uses `//nolint:thelper` instead of marking itself as a test 
helper. Other helpers in this file use `testing.TB` + `Helper()` (e.g. 
`assertInternalError`), which gives better failure locations and avoids 
suppressing the lint rule.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to