浏览代码

test: add more tests (#1209)

Kevin Wan 3 年之前
父节点
当前提交
d011316997
共有 1 个文件被更改,包括 30 次插入0 次删除
  1. 30 0
      zrpc/client_test.go

+ 30 - 0
zrpc/client_test.go

@@ -82,6 +82,34 @@ func TestDepositServer_Deposit(t *testing.T) {
 			return invoker(ctx, method, req, reply, cc, opts...)
 			return invoker(ctx, method, req, reply, cc, opts...)
 		}),
 		}),
 	)
 	)
+	nonBlockClient := MustNewClient(
+		RpcClientConf{
+			Endpoints: []string{"foo"},
+			App:       "foo",
+			Token:     "bar",
+			Timeout:   1000,
+			NonBlock:  true,
+		},
+		WithDialOption(grpc.WithContextDialer(dialer())),
+		WithUnaryClientInterceptor(func(ctx context.Context, method string, req, reply interface{},
+			cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
+			return invoker(ctx, method, req, reply, cc, opts...)
+		}),
+	)
+	retryClient := MustNewClient(
+		RpcClientConf{
+			Endpoints: []string{"foo"},
+			App:       "foo",
+			Token:     "bar",
+			Timeout:   1000,
+			Retry:     true,
+		},
+		WithDialOption(grpc.WithContextDialer(dialer())),
+		WithUnaryClientInterceptor(func(ctx context.Context, method string, req, reply interface{},
+			cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
+			return invoker(ctx, method, req, reply, cc, opts...)
+		}),
+	)
 	tarConfClient := MustNewClient(
 	tarConfClient := MustNewClient(
 		RpcClientConf{
 		RpcClientConf{
 			Target:  "foo",
 			Target:  "foo",
@@ -105,6 +133,8 @@ func TestDepositServer_Deposit(t *testing.T) {
 	assert.Nil(t, err)
 	assert.Nil(t, err)
 	clients := []Client{
 	clients := []Client{
 		directClient,
 		directClient,
+		nonBlockClient,
+		retryClient,
 		tarConfClient,
 		tarConfClient,
 		targetClient,
 		targetClient,
 	}
 	}