-
Notifications
You must be signed in to change notification settings - Fork 1
/
api_moq_test.go
380 lines (352 loc) · 12.4 KB
/
api_moq_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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
// Code generated by moq; DO NOT EDIT.
// github.com/matryer/moq
package trapcheck
import (
"github.com/circonus-labs/go-apiclient"
"sync"
)
// Ensure, that APIMock does implement API.
// If this is not the case, regenerate this file with moq.
var _ API = &APIMock{}
// APIMock is a mock implementation of API.
//
// func TestSomethingThatUsesAPI(t *testing.T) {
//
// // make and configure a mocked API
// mockedAPI := &APIMock{
// CreateCheckBundleFunc: func(cfg *apiclient.CheckBundle) (*apiclient.CheckBundle, error) {
// panic("mock out the CreateCheckBundle method")
// },
// FetchBrokerFunc: func(cid apiclient.CIDType) (*apiclient.Broker, error) {
// panic("mock out the FetchBroker method")
// },
// FetchBrokersFunc: func() (*[]apiclient.Broker, error) {
// panic("mock out the FetchBrokers method")
// },
// FetchCheckBundleFunc: func(cid apiclient.CIDType) (*apiclient.CheckBundle, error) {
// panic("mock out the FetchCheckBundle method")
// },
// GetFunc: func(requrl string) ([]byte, error) {
// panic("mock out the Get method")
// },
// SearchBrokersFunc: func(searchCriteria *apiclient.SearchQueryType, filterCriteria *apiclient.SearchFilterType) (*[]apiclient.Broker, error) {
// panic("mock out the SearchBrokers method")
// },
// SearchCheckBundlesFunc: func(searchCriteria *apiclient.SearchQueryType, filterCriteria *apiclient.SearchFilterType) (*[]apiclient.CheckBundle, error) {
// panic("mock out the SearchCheckBundles method")
// },
// UpdateCheckBundleFunc: func(cfg *apiclient.CheckBundle) (*apiclient.CheckBundle, error) {
// panic("mock out the UpdateCheckBundle method")
// },
// }
//
// // use mockedAPI in code that requires API
// // and then make assertions.
//
// }
type APIMock struct {
// CreateCheckBundleFunc mocks the CreateCheckBundle method.
CreateCheckBundleFunc func(cfg *apiclient.CheckBundle) (*apiclient.CheckBundle, error)
// FetchBrokerFunc mocks the FetchBroker method.
FetchBrokerFunc func(cid apiclient.CIDType) (*apiclient.Broker, error)
// FetchBrokersFunc mocks the FetchBrokers method.
FetchBrokersFunc func() (*[]apiclient.Broker, error)
// FetchCheckBundleFunc mocks the FetchCheckBundle method.
FetchCheckBundleFunc func(cid apiclient.CIDType) (*apiclient.CheckBundle, error)
// GetFunc mocks the Get method.
GetFunc func(requrl string) ([]byte, error)
// SearchBrokersFunc mocks the SearchBrokers method.
SearchBrokersFunc func(searchCriteria *apiclient.SearchQueryType, filterCriteria *apiclient.SearchFilterType) (*[]apiclient.Broker, error)
// SearchCheckBundlesFunc mocks the SearchCheckBundles method.
SearchCheckBundlesFunc func(searchCriteria *apiclient.SearchQueryType, filterCriteria *apiclient.SearchFilterType) (*[]apiclient.CheckBundle, error)
// UpdateCheckBundleFunc mocks the UpdateCheckBundle method.
UpdateCheckBundleFunc func(cfg *apiclient.CheckBundle) (*apiclient.CheckBundle, error)
// calls tracks calls to the methods.
calls struct {
// CreateCheckBundle holds details about calls to the CreateCheckBundle method.
CreateCheckBundle []struct {
// Cfg is the cfg argument value.
Cfg *apiclient.CheckBundle
}
// FetchBroker holds details about calls to the FetchBroker method.
FetchBroker []struct {
// Cid is the cid argument value.
Cid apiclient.CIDType
}
// FetchBrokers holds details about calls to the FetchBrokers method.
FetchBrokers []struct {
}
// FetchCheckBundle holds details about calls to the FetchCheckBundle method.
FetchCheckBundle []struct {
// Cid is the cid argument value.
Cid apiclient.CIDType
}
// Get holds details about calls to the Get method.
Get []struct {
// Requrl is the requrl argument value.
Requrl string
}
// SearchBrokers holds details about calls to the SearchBrokers method.
SearchBrokers []struct {
// SearchCriteria is the searchCriteria argument value.
SearchCriteria *apiclient.SearchQueryType
// FilterCriteria is the filterCriteria argument value.
FilterCriteria *apiclient.SearchFilterType
}
// SearchCheckBundles holds details about calls to the SearchCheckBundles method.
SearchCheckBundles []struct {
// SearchCriteria is the searchCriteria argument value.
SearchCriteria *apiclient.SearchQueryType
// FilterCriteria is the filterCriteria argument value.
FilterCriteria *apiclient.SearchFilterType
}
// UpdateCheckBundle holds details about calls to the UpdateCheckBundle method.
UpdateCheckBundle []struct {
// Cfg is the cfg argument value.
Cfg *apiclient.CheckBundle
}
}
lockCreateCheckBundle sync.RWMutex
lockFetchBroker sync.RWMutex
lockFetchBrokers sync.RWMutex
lockFetchCheckBundle sync.RWMutex
lockGet sync.RWMutex
lockSearchBrokers sync.RWMutex
lockSearchCheckBundles sync.RWMutex
lockUpdateCheckBundle sync.RWMutex
}
// CreateCheckBundle calls CreateCheckBundleFunc.
func (mock *APIMock) CreateCheckBundle(cfg *apiclient.CheckBundle) (*apiclient.CheckBundle, error) {
if mock.CreateCheckBundleFunc == nil {
panic("APIMock.CreateCheckBundleFunc: method is nil but API.CreateCheckBundle was just called")
}
callInfo := struct {
Cfg *apiclient.CheckBundle
}{
Cfg: cfg,
}
mock.lockCreateCheckBundle.Lock()
mock.calls.CreateCheckBundle = append(mock.calls.CreateCheckBundle, callInfo)
mock.lockCreateCheckBundle.Unlock()
return mock.CreateCheckBundleFunc(cfg)
}
// CreateCheckBundleCalls gets all the calls that were made to CreateCheckBundle.
// Check the length with:
// len(mockedAPI.CreateCheckBundleCalls())
func (mock *APIMock) CreateCheckBundleCalls() []struct {
Cfg *apiclient.CheckBundle
} {
var calls []struct {
Cfg *apiclient.CheckBundle
}
mock.lockCreateCheckBundle.RLock()
calls = mock.calls.CreateCheckBundle
mock.lockCreateCheckBundle.RUnlock()
return calls
}
// FetchBroker calls FetchBrokerFunc.
func (mock *APIMock) FetchBroker(cid apiclient.CIDType) (*apiclient.Broker, error) {
if mock.FetchBrokerFunc == nil {
panic("APIMock.FetchBrokerFunc: method is nil but API.FetchBroker was just called")
}
callInfo := struct {
Cid apiclient.CIDType
}{
Cid: cid,
}
mock.lockFetchBroker.Lock()
mock.calls.FetchBroker = append(mock.calls.FetchBroker, callInfo)
mock.lockFetchBroker.Unlock()
return mock.FetchBrokerFunc(cid)
}
// FetchBrokerCalls gets all the calls that were made to FetchBroker.
// Check the length with:
// len(mockedAPI.FetchBrokerCalls())
func (mock *APIMock) FetchBrokerCalls() []struct {
Cid apiclient.CIDType
} {
var calls []struct {
Cid apiclient.CIDType
}
mock.lockFetchBroker.RLock()
calls = mock.calls.FetchBroker
mock.lockFetchBroker.RUnlock()
return calls
}
// FetchBrokers calls FetchBrokersFunc.
func (mock *APIMock) FetchBrokers() (*[]apiclient.Broker, error) {
if mock.FetchBrokersFunc == nil {
panic("APIMock.FetchBrokersFunc: method is nil but API.FetchBrokers was just called")
}
callInfo := struct {
}{}
mock.lockFetchBrokers.Lock()
mock.calls.FetchBrokers = append(mock.calls.FetchBrokers, callInfo)
mock.lockFetchBrokers.Unlock()
return mock.FetchBrokersFunc()
}
// FetchBrokersCalls gets all the calls that were made to FetchBrokers.
// Check the length with:
// len(mockedAPI.FetchBrokersCalls())
func (mock *APIMock) FetchBrokersCalls() []struct {
} {
var calls []struct {
}
mock.lockFetchBrokers.RLock()
calls = mock.calls.FetchBrokers
mock.lockFetchBrokers.RUnlock()
return calls
}
// FetchCheckBundle calls FetchCheckBundleFunc.
func (mock *APIMock) FetchCheckBundle(cid apiclient.CIDType) (*apiclient.CheckBundle, error) {
if mock.FetchCheckBundleFunc == nil {
panic("APIMock.FetchCheckBundleFunc: method is nil but API.FetchCheckBundle was just called")
}
callInfo := struct {
Cid apiclient.CIDType
}{
Cid: cid,
}
mock.lockFetchCheckBundle.Lock()
mock.calls.FetchCheckBundle = append(mock.calls.FetchCheckBundle, callInfo)
mock.lockFetchCheckBundle.Unlock()
return mock.FetchCheckBundleFunc(cid)
}
// FetchCheckBundleCalls gets all the calls that were made to FetchCheckBundle.
// Check the length with:
// len(mockedAPI.FetchCheckBundleCalls())
func (mock *APIMock) FetchCheckBundleCalls() []struct {
Cid apiclient.CIDType
} {
var calls []struct {
Cid apiclient.CIDType
}
mock.lockFetchCheckBundle.RLock()
calls = mock.calls.FetchCheckBundle
mock.lockFetchCheckBundle.RUnlock()
return calls
}
// Get calls GetFunc.
func (mock *APIMock) Get(requrl string) ([]byte, error) {
if mock.GetFunc == nil {
panic("APIMock.GetFunc: method is nil but API.Get was just called")
}
callInfo := struct {
Requrl string
}{
Requrl: requrl,
}
mock.lockGet.Lock()
mock.calls.Get = append(mock.calls.Get, callInfo)
mock.lockGet.Unlock()
return mock.GetFunc(requrl)
}
// GetCalls gets all the calls that were made to Get.
// Check the length with:
// len(mockedAPI.GetCalls())
func (mock *APIMock) GetCalls() []struct {
Requrl string
} {
var calls []struct {
Requrl string
}
mock.lockGet.RLock()
calls = mock.calls.Get
mock.lockGet.RUnlock()
return calls
}
// SearchBrokers calls SearchBrokersFunc.
func (mock *APIMock) SearchBrokers(searchCriteria *apiclient.SearchQueryType, filterCriteria *apiclient.SearchFilterType) (*[]apiclient.Broker, error) {
if mock.SearchBrokersFunc == nil {
panic("APIMock.SearchBrokersFunc: method is nil but API.SearchBrokers was just called")
}
callInfo := struct {
SearchCriteria *apiclient.SearchQueryType
FilterCriteria *apiclient.SearchFilterType
}{
SearchCriteria: searchCriteria,
FilterCriteria: filterCriteria,
}
mock.lockSearchBrokers.Lock()
mock.calls.SearchBrokers = append(mock.calls.SearchBrokers, callInfo)
mock.lockSearchBrokers.Unlock()
return mock.SearchBrokersFunc(searchCriteria, filterCriteria)
}
// SearchBrokersCalls gets all the calls that were made to SearchBrokers.
// Check the length with:
// len(mockedAPI.SearchBrokersCalls())
func (mock *APIMock) SearchBrokersCalls() []struct {
SearchCriteria *apiclient.SearchQueryType
FilterCriteria *apiclient.SearchFilterType
} {
var calls []struct {
SearchCriteria *apiclient.SearchQueryType
FilterCriteria *apiclient.SearchFilterType
}
mock.lockSearchBrokers.RLock()
calls = mock.calls.SearchBrokers
mock.lockSearchBrokers.RUnlock()
return calls
}
// SearchCheckBundles calls SearchCheckBundlesFunc.
func (mock *APIMock) SearchCheckBundles(searchCriteria *apiclient.SearchQueryType, filterCriteria *apiclient.SearchFilterType) (*[]apiclient.CheckBundle, error) {
if mock.SearchCheckBundlesFunc == nil {
panic("APIMock.SearchCheckBundlesFunc: method is nil but API.SearchCheckBundles was just called")
}
callInfo := struct {
SearchCriteria *apiclient.SearchQueryType
FilterCriteria *apiclient.SearchFilterType
}{
SearchCriteria: searchCriteria,
FilterCriteria: filterCriteria,
}
mock.lockSearchCheckBundles.Lock()
mock.calls.SearchCheckBundles = append(mock.calls.SearchCheckBundles, callInfo)
mock.lockSearchCheckBundles.Unlock()
return mock.SearchCheckBundlesFunc(searchCriteria, filterCriteria)
}
// SearchCheckBundlesCalls gets all the calls that were made to SearchCheckBundles.
// Check the length with:
// len(mockedAPI.SearchCheckBundlesCalls())
func (mock *APIMock) SearchCheckBundlesCalls() []struct {
SearchCriteria *apiclient.SearchQueryType
FilterCriteria *apiclient.SearchFilterType
} {
var calls []struct {
SearchCriteria *apiclient.SearchQueryType
FilterCriteria *apiclient.SearchFilterType
}
mock.lockSearchCheckBundles.RLock()
calls = mock.calls.SearchCheckBundles
mock.lockSearchCheckBundles.RUnlock()
return calls
}
// UpdateCheckBundle calls UpdateCheckBundleFunc.
func (mock *APIMock) UpdateCheckBundle(cfg *apiclient.CheckBundle) (*apiclient.CheckBundle, error) {
if mock.UpdateCheckBundleFunc == nil {
panic("APIMock.UpdateCheckBundleFunc: method is nil but API.UpdateCheckBundle was just called")
}
callInfo := struct {
Cfg *apiclient.CheckBundle
}{
Cfg: cfg,
}
mock.lockUpdateCheckBundle.Lock()
mock.calls.UpdateCheckBundle = append(mock.calls.UpdateCheckBundle, callInfo)
mock.lockUpdateCheckBundle.Unlock()
return mock.UpdateCheckBundleFunc(cfg)
}
// UpdateCheckBundleCalls gets all the calls that were made to UpdateCheckBundle.
// Check the length with:
// len(mockedAPI.UpdateCheckBundleCalls())
func (mock *APIMock) UpdateCheckBundleCalls() []struct {
Cfg *apiclient.CheckBundle
} {
var calls []struct {
Cfg *apiclient.CheckBundle
}
mock.lockUpdateCheckBundle.RLock()
calls = mock.calls.UpdateCheckBundle
mock.lockUpdateCheckBundle.RUnlock()
return calls
}