You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-zero/zrpc/internal/serverinterceptors/prometheusinterceptor_test.go

33 lines
787 B
Go

4 years ago
package serverinterceptors
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/zeromicro/go-zero/core/prometheus"
4 years ago
"google.golang.org/grpc"
)
func TestUnaryPromMetricInterceptor_Disabled(t *testing.T) {
_, err := UnaryPrometheusInterceptor(context.Background(), nil, &grpc.UnaryServerInfo{
FullMethod: "/",
}, func(ctx context.Context, req any) (any, error) {
return nil, nil
})
assert.Nil(t, err)
}
func TestUnaryPromMetricInterceptor_Enabled(t *testing.T) {
prometheus.StartAgent(prometheus.Config{
Host: "localhost",
Path: "/",
})
_, err := UnaryPrometheusInterceptor(context.Background(), nil, &grpc.UnaryServerInfo{
4 years ago
FullMethod: "/",
}, func(ctx context.Context, req any) (any, error) {
4 years ago
return nil, nil
})
assert.Nil(t, err)
}