-
Notifications
You must be signed in to change notification settings - Fork 929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
triple test #2391
triple test #2391
Conversation
Kudos, SonarCloud Quality Gate passed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not modify any files other than /protocol/triple
The rest of these changes appear to be ide one-click changes. I would pull it back, make changes in the specified package, and then remove the unused code |
// *http.Client! | ||
var httpClient = examplePingServer.Client() | ||
|
||
// By default, clients use the Connect protocol. Add triple.WithGRPC() or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default, clients use the Triple protocol.
examplePingServer.URL(), | ||
) | ||
response := tri.NewResponse(&pingv1.PingResponse{}) | ||
err := client.Ping( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if err := client.Ping... err != nil
There is no need to declare a var in the func scope when it would not be used anymore.
validateExpectedError := func(t *testing.T, err error) { | ||
t.Helper() | ||
assert.NotNil(t, err) | ||
var connectErr *triple.Error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var tripleErr *triple.Error
) | ||
ctx := context.Background() | ||
// unary | ||
//err := client.Ping(ctx, triple.NewRequest(nil), triple.NewResponse(&pingv1.PingResponse{})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please think about this case.
//assert.Nil(t, err) | ||
text := strings.Repeat(".", 256) | ||
msg := &pingv1.PingResponse{} | ||
err1 := client.Ping(ctx, triple.NewRequest(&pingv1.PingRequest{Text: text}), triple.NewResponse(msg)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use err.
res := NewResponse(pingv1.PingResponse{}) | ||
assert.True(t, stream.Receive(res)) | ||
first := fmt.Sprintf("%p", stream.Msg()) | ||
res1 := NewResponse(pingv1.PingResponse{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto.
func TestServerStreamForClient(t *testing.T) { | ||
t.Parallel() | ||
stream := &ServerStreamForClient{conn: &nopStreamingClientConn{}} | ||
// Ensure that each call to Receive allocates a new message. This helps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this comment cause it has nothing to do with triple.
bidiStream := &BidiStreamForClient{err: initErr} | ||
res := NewResponse(pingv1.CumSumResponse{}) | ||
err := bidiStream.Receive(res) | ||
//assert.Nil(t, res) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this statement.
t.Parallel() | ||
initErr := errors.New("client init failure") | ||
bidiStream := &BidiStreamForClient{err: initErr} | ||
res := NewResponse(pingv1.CumSumResponse{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto.
@@ -220,7 +220,7 @@ func (m *codecMap) Names() []string { | |||
|
|||
func errNotProto(message any) error { | |||
if _, ok := message.(protoiface.MessageV1); ok { | |||
return fmt.Errorf("%T uses github.com/golang/protobuf, but connect-go only supports google.golang.org/protobuf: see https://go.dev/blog/protobuf-apiv2", message) | |||
return fmt.Errorf("%T uses github.com/golang/protobuf, but triple-go only supports google.golang.org/protobuf: see https://go.dev/blog/protobuf-apiv2", message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use triple not triple-go
Unit testing of the triple protocol is completed