statinterceptor_test.go 505 B

12345678910111213141516171819202122
  1. package serverinterceptors
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/stretchr/testify/assert"
  6. "github.com/tal-tech/go-zero/core/stat"
  7. "google.golang.org/grpc"
  8. )
  9. func TestUnaryStatInterceptor(t *testing.T) {
  10. metrics := stat.NewMetrics("mock")
  11. interceptor := UnaryStatInterceptor(metrics)
  12. _, err := interceptor(context.Background(), nil, &grpc.UnaryServerInfo{
  13. FullMethod: "/",
  14. }, func(
  15. ctx context.Context, req interface{}) (interface{}, error) {
  16. return nil, nil
  17. })
  18. assert.Nil(t, err)
  19. }