timeoutinterceptor_test.go 456 B

123456789101112131415161718192021
  1. package serverinterceptors
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "github.com/stretchr/testify/assert"
  7. "google.golang.org/grpc"
  8. )
  9. func TestUnaryTimeoutInterceptor(t *testing.T) {
  10. interceptor := UnaryTimeoutInterceptor(time.Millisecond * 10)
  11. _, err := interceptor(context.Background(), nil, &grpc.UnaryServerInfo{
  12. FullMethod: "/",
  13. }, func(
  14. ctx context.Context, req interface{}) (interface{}, error) {
  15. return nil, nil
  16. })
  17. assert.Nil(t, err)
  18. }