-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmocks_test.go
354 lines (269 loc) · 6.97 KB
/
mocks_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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
package servicefoundation_test
import (
"io"
"net/http"
"time"
sf "github.com/Travix-International/go-servicefoundation"
"github.com/julienschmidt/httprouter"
"github.com/stretchr/testify/mock"
)
/* http.ResponseWriter mock */
type mockResponseWriter struct {
mock.Mock
sf.WrappedResponseWriter
http.Flusher
}
func (m *mockResponseWriter) Header() http.Header {
a := m.Called()
return a.Get(0).(http.Header)
}
func (m *mockResponseWriter) Write(b []byte) (int, error) {
a := m.Called(b)
return a.Get(0).(int), a.Error(1)
}
func (m *mockResponseWriter) WriteHeader(i int) {
m.Called(i)
}
func (m *mockResponseWriter) JSON(statusCode int, content interface{}) {
m.Called(statusCode, content)
}
func (m *mockResponseWriter) XML(statusCode int, content interface{}) {
m.Called(statusCode, content)
}
func (m *mockResponseWriter) AcceptsXML(r *http.Request) bool {
a := m.Called(r)
return a.Bool(0)
}
func (m *mockResponseWriter) WriteResponse(r *http.Request, statusCode int, content interface{}) {
m.Called(r, statusCode, content)
}
func (m *mockResponseWriter) SetCaching(maxAge int) {
m.Called(maxAge)
}
func (m *mockResponseWriter) Status() int {
a := m.Called()
return a.Int(0)
}
func (m *mockResponseWriter) Flush() {
m.Called()
}
/* io.Reader mock */
type mockReader struct {
mock.Mock
io.ReadCloser
}
func (m *mockReader) Read(p []byte) (n int, err error) {
a := m.Called(p)
return a.Get(0).(int), a.Error(1)
}
func (m *mockReader) Close() error {
a := m.Called()
return a.Error(0)
}
/* sf.LogFactory mock */
type mockLogFactory struct {
mock.Mock
sf.LogFactory
}
func (m *mockLogFactory) NewLogger(meta map[string]string) sf.Logger {
i := m.Called(meta)
return i.Get(0).(sf.Logger)
}
/* sf.Logger mock */
type mockLogger struct {
mock.Mock
sf.Logger
}
func (m *mockLogger) Debug(event, formatOrMsg string, a ...interface{}) {
m.Called(event, formatOrMsg, a)
}
func (m *mockLogger) Info(event, formatOrMsg string, a ...interface{}) {
m.Called(event, formatOrMsg, a)
}
func (m *mockLogger) Warn(event, formatOrMsg string, a ...interface{}) {
m.Called(event, formatOrMsg, a)
}
func (m *mockLogger) Error(event, formatOrMsg string, a ...interface{}) {
m.Called(event, formatOrMsg, a)
}
/* sf.Metrics mock */
type (
mockMetrics struct {
mock.Mock
sf.Metrics
}
mockHistogramVec struct {
mock.Mock
sf.HistogramVec
}
mockSummaryVec struct {
mock.Mock
sf.SummaryVec
}
)
func (m *mockHistogramVec) RecordTimeElapsed(start time.Time) {
m.Called(start)
}
func (m *mockHistogramVec) RecordDuration(start time.Time, unit time.Duration) {
m.Called(start, unit)
}
func (m *mockSummaryVec) RecordTimeElapsed(start time.Time) {
m.Called(start)
}
func (m *mockSummaryVec) RecordDuration(start time.Time, unit time.Duration) {
m.Called(start, unit)
}
func (m *mockMetrics) Count(subsystem, name, help string) {
m.Called(subsystem, name, help)
}
func (m *mockMetrics) SetGauge(value float64, subsystem, name, help string) {
m.Called(value, subsystem, name, help)
}
func (m *mockMetrics) CountLabels(subsystem, name, help string, labels, values []string) {
m.Called(subsystem, name, help, labels, values)
}
func (m *mockMetrics) IncreaseCounter(subsystem, name, help string, increment int) {
m.Called(subsystem, name, help, increment)
}
func (m *mockMetrics) AddHistogramVec(subsystem, name, help string, labels, labelValues []string) sf.HistogramVec {
a := m.Called(subsystem, name, help, labels, labelValues)
return a.Get(0).(sf.HistogramVec)
}
func (m *mockMetrics) AddSummaryVec(subsystem, name, help string, labels, labelValues []string) sf.SummaryVec {
a := m.Called(subsystem, name, help, labels, labelValues)
return a.Get(0).(sf.SummaryVec)
}
/* sf.VersionBuilder mock */
type mockVersionBuilder struct {
mock.Mock
sf.VersionBuilder
}
func (m *mockVersionBuilder) ToString() string {
a := m.Called()
return a.String(0)
}
func (m *mockVersionBuilder) ToMap() map[string]string {
a := m.Called()
return a.Get(0).(map[string]string)
}
/* sf.MiddlewareWrapper mock */
type mockMiddlewareWrapper struct {
mock.Mock
sf.MiddlewareWrapper
}
func (m *mockMiddlewareWrapper) Wrap(subsystem, name string, middleware sf.Middleware, handler sf.Handle, metaFunc sf.MetaFunc) sf.Handle {
a := m.Called(subsystem, name, middleware, handler, metaFunc)
return a.Get(0).(func(sf.WrappedResponseWriter, *http.Request, sf.RouterParams))
}
/* sf.RouterFactory mock */
type mockRouterFactory struct {
mock.Mock
sf.RouterFactory
}
func (m *mockRouterFactory) NewRouter() *sf.Router {
a := m.Called()
return a.Get(0).(*sf.Router)
}
/* sf.ServiceHandlerFactory mock */
type mockServiceHandlerFactory struct {
mock.Mock
sf.ServiceHandlerFactory
}
func (m *mockServiceHandlerFactory) Wrap(subsystem, name string, middlewares []sf.Middleware, handle sf.Handle,
metaFunc sf.MetaFunc) httprouter.Handle {
a := m.Called(subsystem, name, middlewares, handle, metaFunc)
return a.Get(0).(httprouter.Handle)
}
func (m *mockServiceHandlerFactory) NewHandlers() *sf.Handlers {
a := m.Called()
return a.Get(0).(*sf.Handlers)
}
/* sf.RootHandler mock */
type mockRootHandler struct {
mock.Mock
sf.RootHandler
}
func (m *mockRootHandler) NewRootHandler() sf.Handle {
a := m.Called()
return a.Get(0).(sf.Handle)
}
/* sf.ReadinessHandler mock */
type mockReadinessHandler struct {
mock.Mock
sf.ReadinessHandler
}
func (m *mockReadinessHandler) NewReadinessHandler() sf.Handle {
a := m.Called()
return a.Get(0).(sf.Handle)
}
/* sf.LivenessHandler mock */
type mockLivenessHandler struct {
mock.Mock
sf.LivenessHandler
}
func (m *mockLivenessHandler) NewLivenessHandler() sf.Handle {
a := m.Called()
return a.Get(0).(sf.Handle)
}
/* sf.QuitHandler mock */
type mockQuitHandler struct {
mock.Mock
sf.QuitHandler
}
func (m *mockQuitHandler) NewQuitHandler() sf.Handle {
a := m.Called()
return a.Get(0).(sf.Handle)
}
/* sf.HealthHandler mock */
type mockHealthHandler struct {
mock.Mock
sf.HealthHandler
}
func (m *mockHealthHandler) NewHealthHandler() sf.Handle {
a := m.Called()
return a.Get(0).(sf.Handle)
}
/* sf.RootHandler mock */
type mockVersionHandler struct {
mock.Mock
sf.VersionHandler
}
func (m *mockVersionHandler) NewVersionHandler() sf.Handle {
a := m.Called()
return a.Get(0).(sf.Handle)
}
/* sf.MetricsHandler mock */
type mockMetricsHandler struct {
mock.Mock
sf.MetricsHandler
}
func (m *mockMetricsHandler) NewMetricsHandler() sf.Handle {
a := m.Called()
return a.Get(0).(sf.Handle)
}
/* sf.PreFlightHandler mock */
type mockPreFlightHandler struct {
mock.Mock
sf.PreFlightHandler
}
func (m *mockPreFlightHandler) NewPreFlightHandler() sf.Handle {
a := m.Called()
return a.Get(0).(sf.Handle)
}
/* sf.ServiceStateReader mock */
type mockServiceStateReader struct {
mock.Mock
sf.ServiceStateReader
}
func (m *mockServiceStateReader) IsLive() bool {
a := m.Called()
return a.Bool(0)
}
func (m *mockServiceStateReader) IsReady() bool {
a := m.Called()
return a.Bool(0)
}
func (m *mockServiceStateReader) IsHealthy() bool {
a := m.Called()
return a.Bool(0)
}