-
Notifications
You must be signed in to change notification settings - Fork 40
/
recorder.go
42 lines (34 loc) · 860 Bytes
/
recorder.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package testutil
import (
"github.com/prometheus/client_golang/prometheus"
dto "github.com/prometheus/client_model/go"
"github.com/stretchr/testify/mock"
)
// Summary is a mock object for `prometheus.Summary`
type Summary struct {
mock.Mock
}
func (s *Summary) Observe(d float64) {
s.Called(d)
}
// implement `prometheus.Metric` interface
func (s *Summary) Desc() *prometheus.Desc {
s.Called()
return &prometheus.Desc{}
}
// implement `prometheus.Metric` interface
func (s *Summary) Write(m *dto.Metric) error {
args := s.Called(m)
return args.Error(0)
}
// implement `prometheus.Collector` interface
func (s *Summary) Describe(c chan<- *prometheus.Desc) {
s.Called(c)
}
// implement `prometheus.Collector` interface
func (s *Summary) Collect(m chan<- prometheus.Metric) {
s.Called(m)
}
func NewSummaryMock() *Summary {
return &Summary{}
}