This repository has been archived by the owner on Oct 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathmock_metricsservice_test.go
153 lines (130 loc) · 5.87 KB
/
mock_metricsservice_test.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
// Code generated by pegomock. DO NOT EDIT.
// Source: github.com/cloudfoundry-incubator/bits-service (interfaces: MetricsService)
package bitsgo_test
import (
pegomock "github.com/petergtz/pegomock"
"reflect"
time "time"
)
type MockMetricsService struct {
fail func(message string, callerSkip ...int)
}
func NewMockMetricsService() *MockMetricsService {
return &MockMetricsService{fail: pegomock.GlobalFailHandler}
}
func (mock *MockMetricsService) SendTimingMetric(name string, duration time.Duration) {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockMetricsService().")
}
params := []pegomock.Param{name, duration}
pegomock.GetGenericMockFrom(mock).Invoke("SendTimingMetric", params, []reflect.Type{})
}
func (mock *MockMetricsService) SendGaugeMetric(name string, value int64) {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockMetricsService().")
}
params := []pegomock.Param{name, value}
pegomock.GetGenericMockFrom(mock).Invoke("SendGaugeMetric", params, []reflect.Type{})
}
func (mock *MockMetricsService) SendCounterMetric(name string, value int64) {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockMetricsService().")
}
params := []pegomock.Param{name, value}
pegomock.GetGenericMockFrom(mock).Invoke("SendCounterMetric", params, []reflect.Type{})
}
func (mock *MockMetricsService) VerifyWasCalledOnce() *VerifierMetricsService {
return &VerifierMetricsService{mock, pegomock.Times(1), nil}
}
func (mock *MockMetricsService) VerifyWasCalled(invocationCountMatcher pegomock.Matcher) *VerifierMetricsService {
return &VerifierMetricsService{mock, invocationCountMatcher, nil}
}
func (mock *MockMetricsService) VerifyWasCalledInOrder(invocationCountMatcher pegomock.Matcher, inOrderContext *pegomock.InOrderContext) *VerifierMetricsService {
return &VerifierMetricsService{mock, invocationCountMatcher, inOrderContext}
}
type VerifierMetricsService struct {
mock *MockMetricsService
invocationCountMatcher pegomock.Matcher
inOrderContext *pegomock.InOrderContext
}
func (verifier *VerifierMetricsService) SendTimingMetric(name string, duration time.Duration) *MetricsService_SendTimingMetric_OngoingVerification {
params := []pegomock.Param{name, duration}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "SendTimingMetric", params)
return &MetricsService_SendTimingMetric_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
}
type MetricsService_SendTimingMetric_OngoingVerification struct {
mock *MockMetricsService
methodInvocations []pegomock.MethodInvocation
}
func (c *MetricsService_SendTimingMetric_OngoingVerification) GetCapturedArguments() (string, time.Duration) {
name, duration := c.GetAllCapturedArguments()
return name[len(name)-1], duration[len(duration)-1]
}
func (c *MetricsService_SendTimingMetric_OngoingVerification) GetAllCapturedArguments() (_param0 []string, _param1 []time.Duration) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
_param0 = make([]string, len(params[0]))
for u, param := range params[0] {
_param0[u] = param.(string)
}
_param1 = make([]time.Duration, len(params[1]))
for u, param := range params[1] {
_param1[u] = param.(time.Duration)
}
}
return
}
func (verifier *VerifierMetricsService) SendGaugeMetric(name string, value int64) *MetricsService_SendGaugeMetric_OngoingVerification {
params := []pegomock.Param{name, value}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "SendGaugeMetric", params)
return &MetricsService_SendGaugeMetric_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
}
type MetricsService_SendGaugeMetric_OngoingVerification struct {
mock *MockMetricsService
methodInvocations []pegomock.MethodInvocation
}
func (c *MetricsService_SendGaugeMetric_OngoingVerification) GetCapturedArguments() (string, int64) {
name, value := c.GetAllCapturedArguments()
return name[len(name)-1], value[len(value)-1]
}
func (c *MetricsService_SendGaugeMetric_OngoingVerification) GetAllCapturedArguments() (_param0 []string, _param1 []int64) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
_param0 = make([]string, len(params[0]))
for u, param := range params[0] {
_param0[u] = param.(string)
}
_param1 = make([]int64, len(params[1]))
for u, param := range params[1] {
_param1[u] = param.(int64)
}
}
return
}
func (verifier *VerifierMetricsService) SendCounterMetric(name string, value int64) *MetricsService_SendCounterMetric_OngoingVerification {
params := []pegomock.Param{name, value}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "SendCounterMetric", params)
return &MetricsService_SendCounterMetric_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
}
type MetricsService_SendCounterMetric_OngoingVerification struct {
mock *MockMetricsService
methodInvocations []pegomock.MethodInvocation
}
func (c *MetricsService_SendCounterMetric_OngoingVerification) GetCapturedArguments() (string, int64) {
name, value := c.GetAllCapturedArguments()
return name[len(name)-1], value[len(value)-1]
}
func (c *MetricsService_SendCounterMetric_OngoingVerification) GetAllCapturedArguments() (_param0 []string, _param1 []int64) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
_param0 = make([]string, len(params[0]))
for u, param := range params[0] {
_param0[u] = param.(string)
}
_param1 = make([]int64, len(params[1]))
for u, param := range params[1] {
_param1[u] = param.(int64)
}
}
return
}