github.com/milvus-io/milvus-sdk-go/v2@v2.4.1/client/mq_message_test.go (about) 1 package client 2 3 import ( 4 "context" 5 "testing" 6 7 "github.com/golang/protobuf/proto" 8 "github.com/milvus-io/milvus-proto/go-api/v2/commonpb" 9 "github.com/milvus-io/milvus-proto/go-api/v2/milvuspb" 10 "github.com/stretchr/testify/assert" 11 ) 12 13 func TestGrpcClientReplicateMessage(t *testing.T) { 14 { 15 ctx := context.Background() 16 c := testClient(ctx, t) 17 mockServer.SetInjection(MReplicateMessage, func(ctx context.Context, m proto.Message) (proto.Message, error) { 18 return &milvuspb.ReplicateMessageResponse{ 19 Status: &commonpb.Status{ErrorCode: commonpb.ErrorCode_Success}, 20 Position: "hello", 21 }, nil 22 }) 23 resp, err := c.ReplicateMessage(ctx, "ch1", 1000, 1001, 24 nil, nil, nil, WithReplicateMessageMsgBase(&commonpb.MsgBase{})) 25 assert.Nil(t, err) 26 assert.Equal(t, "hello", resp.Position) 27 } 28 29 { 30 ctx := context.Background() 31 c := testClient(ctx, t) 32 mockServer.SetInjection(MReplicateMessage, func(ctx context.Context, m proto.Message) (proto.Message, error) { 33 return &milvuspb.ReplicateMessageResponse{ 34 Status: &commonpb.Status{ErrorCode: commonpb.ErrorCode_UnexpectedError}, 35 }, nil 36 }) 37 _, err := c.ReplicateMessage(ctx, "ch1", 1000, 1001, 38 nil, nil, nil, WithReplicateMessageMsgBase(&commonpb.MsgBase{})) 39 assert.NotNil(t, err) 40 } 41 }