forked from TrueCloudLab/frostfs-api-go
[#263] Implement client for exchanging raw messages using gRPC protocol
Implement gRPC client that can uniformly execute any RPC on the remote server. In the primary implementation, the client is a thin wrapper over gRPC client connection that is required to create the client. In the future, it is planned to expand the library with convenient functionality. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
ae2fb263f1
commit
cf765a61a6
7 changed files with 271 additions and 0 deletions
49
rpc/common/call_test.go
Normal file
49
rpc/common/call_test.go
Normal file
|
@ -0,0 +1,49 @@
|
|||
package common_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/rpc/common"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
const (
|
||||
testServiceName = "test service"
|
||||
testRPCName = "test RPC"
|
||||
)
|
||||
|
||||
func TestCallMethodInfoUnary(t *testing.T) {
|
||||
i := common.CallMethodInfoUnary(testServiceName, testRPCName)
|
||||
|
||||
require.Equal(t, testServiceName, i.Service)
|
||||
require.Equal(t, testRPCName, i.Name)
|
||||
require.False(t, i.ClientStream())
|
||||
require.False(t, i.ServerStream())
|
||||
}
|
||||
|
||||
func TestCallMethodInfoServerStream(t *testing.T) {
|
||||
i := common.CallMethodInfoServerStream(testServiceName, testRPCName)
|
||||
|
||||
require.Equal(t, testServiceName, i.Service)
|
||||
require.Equal(t, testRPCName, i.Name)
|
||||
require.False(t, i.ClientStream())
|
||||
require.True(t, i.ServerStream())
|
||||
}
|
||||
|
||||
func TestCallMethodInfoClientStream(t *testing.T) {
|
||||
i := common.CallMethodInfoClientStream(testServiceName, testRPCName)
|
||||
|
||||
require.Equal(t, testServiceName, i.Service)
|
||||
require.Equal(t, testRPCName, i.Name)
|
||||
require.True(t, i.ClientStream())
|
||||
require.False(t, i.ServerStream())
|
||||
}
|
||||
|
||||
func TestCallMethodInfoBidirectionalStream(t *testing.T) {
|
||||
i := common.CallMethodInfoBidirectionalStream(testServiceName, testRPCName)
|
||||
|
||||
require.Equal(t, testServiceName, i.Service)
|
||||
require.Equal(t, testRPCName, i.Name)
|
||||
require.True(t, i.ClientStream())
|
||||
require.True(t, i.ServerStream())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue