simplify timeoutinterceptor (#840)

Co-authored-by: chenmusheng <chenmusheng@laoyuegou.com>
This commit is contained in:
masonchen2014
2021-07-24 21:51:46 +08:00
committed by GitHub
parent ff7443c6a7
commit cb8d9d413a
4 changed files with 12 additions and 42 deletions

View File

@@ -6,6 +6,7 @@ import (
"log"
"net"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/tal-tech/go-zero/core/logx"
@@ -58,6 +59,13 @@ func TestDepositServer_Deposit(t *testing.T) {
codes.OK,
"",
},
{
"valid request with long handling time",
2000.00,
nil,
codes.DeadlineExceeded,
fmt.Sprintf("context deadline exceeded"),
},
}
directClient := MustNewClient(
@@ -79,7 +87,7 @@ func TestDepositServer_Deposit(t *testing.T) {
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...)
}))
}), WithTimeout(1000*time.Millisecond))
assert.Nil(t, err)
clients := []Client{
directClient,