forked from cloudfoundry/bosh-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fake_natsclient.go
565 lines (517 loc) · 16.5 KB
/
fake_natsclient.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
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
// This file was generated by counterfeiter
package fakes
import (
"sync"
"github.com/cloudfoundry/yagnats"
)
type FakeNATSClient struct {
PingStub func() bool
pingMutex sync.RWMutex
pingArgsForCall []struct{}
pingReturns struct {
result1 bool
}
pingReturnsOnCall map[int]struct {
result1 bool
}
ConnectStub func(connectionProvider yagnats.ConnectionProvider) error
connectMutex sync.RWMutex
connectArgsForCall []struct {
connectionProvider yagnats.ConnectionProvider
}
connectReturns struct {
result1 error
}
connectReturnsOnCall map[int]struct {
result1 error
}
DisconnectStub func()
disconnectMutex sync.RWMutex
disconnectArgsForCall []struct{}
PublishStub func(subject string, payload []byte) error
publishMutex sync.RWMutex
publishArgsForCall []struct {
subject string
payload []byte
}
publishReturns struct {
result1 error
}
publishReturnsOnCall map[int]struct {
result1 error
}
PublishWithReplyToStub func(subject, reply string, payload []byte) error
publishWithReplyToMutex sync.RWMutex
publishWithReplyToArgsForCall []struct {
subject string
reply string
payload []byte
}
publishWithReplyToReturns struct {
result1 error
}
publishWithReplyToReturnsOnCall map[int]struct {
result1 error
}
SubscribeStub func(subject string, callback yagnats.Callback) (int64, error)
subscribeMutex sync.RWMutex
subscribeArgsForCall []struct {
subject string
callback yagnats.Callback
}
subscribeReturns struct {
result1 int64
result2 error
}
subscribeReturnsOnCall map[int]struct {
result1 int64
result2 error
}
SubscribeWithQueueStub func(subject, queue string, callback yagnats.Callback) (int64, error)
subscribeWithQueueMutex sync.RWMutex
subscribeWithQueueArgsForCall []struct {
subject string
queue string
callback yagnats.Callback
}
subscribeWithQueueReturns struct {
result1 int64
result2 error
}
subscribeWithQueueReturnsOnCall map[int]struct {
result1 int64
result2 error
}
UnsubscribeStub func(subscription int64) error
unsubscribeMutex sync.RWMutex
unsubscribeArgsForCall []struct {
subscription int64
}
unsubscribeReturns struct {
result1 error
}
unsubscribeReturnsOnCall map[int]struct {
result1 error
}
UnsubscribeAllStub func(subject string)
unsubscribeAllMutex sync.RWMutex
unsubscribeAllArgsForCall []struct {
subject string
}
BeforeConnectCallbackStub func(callback func())
beforeConnectCallbackMutex sync.RWMutex
beforeConnectCallbackArgsForCall []struct {
callback func()
}
invocations map[string][][]interface{}
invocationsMutex sync.RWMutex
}
func (fake *FakeNATSClient) Ping() bool {
fake.pingMutex.Lock()
ret, specificReturn := fake.pingReturnsOnCall[len(fake.pingArgsForCall)]
fake.pingArgsForCall = append(fake.pingArgsForCall, struct{}{})
fake.recordInvocation("Ping", []interface{}{})
fake.pingMutex.Unlock()
if fake.PingStub != nil {
return fake.PingStub()
}
if specificReturn {
return ret.result1
}
return fake.pingReturns.result1
}
func (fake *FakeNATSClient) PingCallCount() int {
fake.pingMutex.RLock()
defer fake.pingMutex.RUnlock()
return len(fake.pingArgsForCall)
}
func (fake *FakeNATSClient) PingReturns(result1 bool) {
fake.PingStub = nil
fake.pingReturns = struct {
result1 bool
}{result1}
}
func (fake *FakeNATSClient) PingReturnsOnCall(i int, result1 bool) {
fake.PingStub = nil
if fake.pingReturnsOnCall == nil {
fake.pingReturnsOnCall = make(map[int]struct {
result1 bool
})
}
fake.pingReturnsOnCall[i] = struct {
result1 bool
}{result1}
}
func (fake *FakeNATSClient) Connect(connectionProvider yagnats.ConnectionProvider) error {
fake.connectMutex.Lock()
ret, specificReturn := fake.connectReturnsOnCall[len(fake.connectArgsForCall)]
fake.connectArgsForCall = append(fake.connectArgsForCall, struct {
connectionProvider yagnats.ConnectionProvider
}{connectionProvider})
fake.recordInvocation("Connect", []interface{}{connectionProvider})
fake.connectMutex.Unlock()
if fake.ConnectStub != nil {
return fake.ConnectStub(connectionProvider)
}
if specificReturn {
return ret.result1
}
return fake.connectReturns.result1
}
func (fake *FakeNATSClient) ConnectCallCount() int {
fake.connectMutex.RLock()
defer fake.connectMutex.RUnlock()
return len(fake.connectArgsForCall)
}
func (fake *FakeNATSClient) ConnectArgsForCall(i int) yagnats.ConnectionProvider {
fake.connectMutex.RLock()
defer fake.connectMutex.RUnlock()
return fake.connectArgsForCall[i].connectionProvider
}
func (fake *FakeNATSClient) ConnectReturns(result1 error) {
fake.ConnectStub = nil
fake.connectReturns = struct {
result1 error
}{result1}
}
func (fake *FakeNATSClient) ConnectReturnsOnCall(i int, result1 error) {
fake.ConnectStub = nil
if fake.connectReturnsOnCall == nil {
fake.connectReturnsOnCall = make(map[int]struct {
result1 error
})
}
fake.connectReturnsOnCall[i] = struct {
result1 error
}{result1}
}
func (fake *FakeNATSClient) Disconnect() {
fake.disconnectMutex.Lock()
fake.disconnectArgsForCall = append(fake.disconnectArgsForCall, struct{}{})
fake.recordInvocation("Disconnect", []interface{}{})
fake.disconnectMutex.Unlock()
if fake.DisconnectStub != nil {
fake.DisconnectStub()
}
}
func (fake *FakeNATSClient) DisconnectCallCount() int {
fake.disconnectMutex.RLock()
defer fake.disconnectMutex.RUnlock()
return len(fake.disconnectArgsForCall)
}
func (fake *FakeNATSClient) Publish(subject string, payload []byte) error {
var payloadCopy []byte
if payload != nil {
payloadCopy = make([]byte, len(payload))
copy(payloadCopy, payload)
}
fake.publishMutex.Lock()
ret, specificReturn := fake.publishReturnsOnCall[len(fake.publishArgsForCall)]
fake.publishArgsForCall = append(fake.publishArgsForCall, struct {
subject string
payload []byte
}{subject, payloadCopy})
fake.recordInvocation("Publish", []interface{}{subject, payloadCopy})
fake.publishMutex.Unlock()
if fake.PublishStub != nil {
return fake.PublishStub(subject, payload)
}
if specificReturn {
return ret.result1
}
return fake.publishReturns.result1
}
func (fake *FakeNATSClient) PublishCallCount() int {
fake.publishMutex.RLock()
defer fake.publishMutex.RUnlock()
return len(fake.publishArgsForCall)
}
func (fake *FakeNATSClient) PublishArgsForCall(i int) (string, []byte) {
fake.publishMutex.RLock()
defer fake.publishMutex.RUnlock()
return fake.publishArgsForCall[i].subject, fake.publishArgsForCall[i].payload
}
func (fake *FakeNATSClient) PublishReturns(result1 error) {
fake.PublishStub = nil
fake.publishReturns = struct {
result1 error
}{result1}
}
func (fake *FakeNATSClient) PublishReturnsOnCall(i int, result1 error) {
fake.PublishStub = nil
if fake.publishReturnsOnCall == nil {
fake.publishReturnsOnCall = make(map[int]struct {
result1 error
})
}
fake.publishReturnsOnCall[i] = struct {
result1 error
}{result1}
}
func (fake *FakeNATSClient) PublishWithReplyTo(subject string, reply string, payload []byte) error {
var payloadCopy []byte
if payload != nil {
payloadCopy = make([]byte, len(payload))
copy(payloadCopy, payload)
}
fake.publishWithReplyToMutex.Lock()
ret, specificReturn := fake.publishWithReplyToReturnsOnCall[len(fake.publishWithReplyToArgsForCall)]
fake.publishWithReplyToArgsForCall = append(fake.publishWithReplyToArgsForCall, struct {
subject string
reply string
payload []byte
}{subject, reply, payloadCopy})
fake.recordInvocation("PublishWithReplyTo", []interface{}{subject, reply, payloadCopy})
fake.publishWithReplyToMutex.Unlock()
if fake.PublishWithReplyToStub != nil {
return fake.PublishWithReplyToStub(subject, reply, payload)
}
if specificReturn {
return ret.result1
}
return fake.publishWithReplyToReturns.result1
}
func (fake *FakeNATSClient) PublishWithReplyToCallCount() int {
fake.publishWithReplyToMutex.RLock()
defer fake.publishWithReplyToMutex.RUnlock()
return len(fake.publishWithReplyToArgsForCall)
}
func (fake *FakeNATSClient) PublishWithReplyToArgsForCall(i int) (string, string, []byte) {
fake.publishWithReplyToMutex.RLock()
defer fake.publishWithReplyToMutex.RUnlock()
return fake.publishWithReplyToArgsForCall[i].subject, fake.publishWithReplyToArgsForCall[i].reply, fake.publishWithReplyToArgsForCall[i].payload
}
func (fake *FakeNATSClient) PublishWithReplyToReturns(result1 error) {
fake.PublishWithReplyToStub = nil
fake.publishWithReplyToReturns = struct {
result1 error
}{result1}
}
func (fake *FakeNATSClient) PublishWithReplyToReturnsOnCall(i int, result1 error) {
fake.PublishWithReplyToStub = nil
if fake.publishWithReplyToReturnsOnCall == nil {
fake.publishWithReplyToReturnsOnCall = make(map[int]struct {
result1 error
})
}
fake.publishWithReplyToReturnsOnCall[i] = struct {
result1 error
}{result1}
}
func (fake *FakeNATSClient) Subscribe(subject string, callback yagnats.Callback) (int64, error) {
fake.subscribeMutex.Lock()
ret, specificReturn := fake.subscribeReturnsOnCall[len(fake.subscribeArgsForCall)]
fake.subscribeArgsForCall = append(fake.subscribeArgsForCall, struct {
subject string
callback yagnats.Callback
}{subject, callback})
fake.recordInvocation("Subscribe", []interface{}{subject, callback})
fake.subscribeMutex.Unlock()
if fake.SubscribeStub != nil {
return fake.SubscribeStub(subject, callback)
}
if specificReturn {
return ret.result1, ret.result2
}
return fake.subscribeReturns.result1, fake.subscribeReturns.result2
}
func (fake *FakeNATSClient) SubscribeCallCount() int {
fake.subscribeMutex.RLock()
defer fake.subscribeMutex.RUnlock()
return len(fake.subscribeArgsForCall)
}
func (fake *FakeNATSClient) SubscribeArgsForCall(i int) (string, yagnats.Callback) {
fake.subscribeMutex.RLock()
defer fake.subscribeMutex.RUnlock()
return fake.subscribeArgsForCall[i].subject, fake.subscribeArgsForCall[i].callback
}
func (fake *FakeNATSClient) SubscribeReturns(result1 int64, result2 error) {
fake.SubscribeStub = nil
fake.subscribeReturns = struct {
result1 int64
result2 error
}{result1, result2}
}
func (fake *FakeNATSClient) SubscribeReturnsOnCall(i int, result1 int64, result2 error) {
fake.SubscribeStub = nil
if fake.subscribeReturnsOnCall == nil {
fake.subscribeReturnsOnCall = make(map[int]struct {
result1 int64
result2 error
})
}
fake.subscribeReturnsOnCall[i] = struct {
result1 int64
result2 error
}{result1, result2}
}
func (fake *FakeNATSClient) SubscribeWithQueue(subject string, queue string, callback yagnats.Callback) (int64, error) {
fake.subscribeWithQueueMutex.Lock()
ret, specificReturn := fake.subscribeWithQueueReturnsOnCall[len(fake.subscribeWithQueueArgsForCall)]
fake.subscribeWithQueueArgsForCall = append(fake.subscribeWithQueueArgsForCall, struct {
subject string
queue string
callback yagnats.Callback
}{subject, queue, callback})
fake.recordInvocation("SubscribeWithQueue", []interface{}{subject, queue, callback})
fake.subscribeWithQueueMutex.Unlock()
if fake.SubscribeWithQueueStub != nil {
return fake.SubscribeWithQueueStub(subject, queue, callback)
}
if specificReturn {
return ret.result1, ret.result2
}
return fake.subscribeWithQueueReturns.result1, fake.subscribeWithQueueReturns.result2
}
func (fake *FakeNATSClient) SubscribeWithQueueCallCount() int {
fake.subscribeWithQueueMutex.RLock()
defer fake.subscribeWithQueueMutex.RUnlock()
return len(fake.subscribeWithQueueArgsForCall)
}
func (fake *FakeNATSClient) SubscribeWithQueueArgsForCall(i int) (string, string, yagnats.Callback) {
fake.subscribeWithQueueMutex.RLock()
defer fake.subscribeWithQueueMutex.RUnlock()
return fake.subscribeWithQueueArgsForCall[i].subject, fake.subscribeWithQueueArgsForCall[i].queue, fake.subscribeWithQueueArgsForCall[i].callback
}
func (fake *FakeNATSClient) SubscribeWithQueueReturns(result1 int64, result2 error) {
fake.SubscribeWithQueueStub = nil
fake.subscribeWithQueueReturns = struct {
result1 int64
result2 error
}{result1, result2}
}
func (fake *FakeNATSClient) SubscribeWithQueueReturnsOnCall(i int, result1 int64, result2 error) {
fake.SubscribeWithQueueStub = nil
if fake.subscribeWithQueueReturnsOnCall == nil {
fake.subscribeWithQueueReturnsOnCall = make(map[int]struct {
result1 int64
result2 error
})
}
fake.subscribeWithQueueReturnsOnCall[i] = struct {
result1 int64
result2 error
}{result1, result2}
}
func (fake *FakeNATSClient) Unsubscribe(subscription int64) error {
fake.unsubscribeMutex.Lock()
ret, specificReturn := fake.unsubscribeReturnsOnCall[len(fake.unsubscribeArgsForCall)]
fake.unsubscribeArgsForCall = append(fake.unsubscribeArgsForCall, struct {
subscription int64
}{subscription})
fake.recordInvocation("Unsubscribe", []interface{}{subscription})
fake.unsubscribeMutex.Unlock()
if fake.UnsubscribeStub != nil {
return fake.UnsubscribeStub(subscription)
}
if specificReturn {
return ret.result1
}
return fake.unsubscribeReturns.result1
}
func (fake *FakeNATSClient) UnsubscribeCallCount() int {
fake.unsubscribeMutex.RLock()
defer fake.unsubscribeMutex.RUnlock()
return len(fake.unsubscribeArgsForCall)
}
func (fake *FakeNATSClient) UnsubscribeArgsForCall(i int) int64 {
fake.unsubscribeMutex.RLock()
defer fake.unsubscribeMutex.RUnlock()
return fake.unsubscribeArgsForCall[i].subscription
}
func (fake *FakeNATSClient) UnsubscribeReturns(result1 error) {
fake.UnsubscribeStub = nil
fake.unsubscribeReturns = struct {
result1 error
}{result1}
}
func (fake *FakeNATSClient) UnsubscribeReturnsOnCall(i int, result1 error) {
fake.UnsubscribeStub = nil
if fake.unsubscribeReturnsOnCall == nil {
fake.unsubscribeReturnsOnCall = make(map[int]struct {
result1 error
})
}
fake.unsubscribeReturnsOnCall[i] = struct {
result1 error
}{result1}
}
func (fake *FakeNATSClient) UnsubscribeAll(subject string) {
fake.unsubscribeAllMutex.Lock()
fake.unsubscribeAllArgsForCall = append(fake.unsubscribeAllArgsForCall, struct {
subject string
}{subject})
fake.recordInvocation("UnsubscribeAll", []interface{}{subject})
fake.unsubscribeAllMutex.Unlock()
if fake.UnsubscribeAllStub != nil {
fake.UnsubscribeAllStub(subject)
}
}
func (fake *FakeNATSClient) UnsubscribeAllCallCount() int {
fake.unsubscribeAllMutex.RLock()
defer fake.unsubscribeAllMutex.RUnlock()
return len(fake.unsubscribeAllArgsForCall)
}
func (fake *FakeNATSClient) UnsubscribeAllArgsForCall(i int) string {
fake.unsubscribeAllMutex.RLock()
defer fake.unsubscribeAllMutex.RUnlock()
return fake.unsubscribeAllArgsForCall[i].subject
}
func (fake *FakeNATSClient) BeforeConnectCallback(callback func()) {
fake.beforeConnectCallbackMutex.Lock()
fake.beforeConnectCallbackArgsForCall = append(fake.beforeConnectCallbackArgsForCall, struct {
callback func()
}{callback})
fake.recordInvocation("BeforeConnectCallback", []interface{}{callback})
fake.beforeConnectCallbackMutex.Unlock()
if fake.BeforeConnectCallbackStub != nil {
fake.BeforeConnectCallbackStub(callback)
}
}
func (fake *FakeNATSClient) BeforeConnectCallbackCallCount() int {
fake.beforeConnectCallbackMutex.RLock()
defer fake.beforeConnectCallbackMutex.RUnlock()
return len(fake.beforeConnectCallbackArgsForCall)
}
func (fake *FakeNATSClient) BeforeConnectCallbackArgsForCall(i int) func() {
fake.beforeConnectCallbackMutex.RLock()
defer fake.beforeConnectCallbackMutex.RUnlock()
return fake.beforeConnectCallbackArgsForCall[i].callback
}
func (fake *FakeNATSClient) Invocations() map[string][][]interface{} {
fake.invocationsMutex.RLock()
defer fake.invocationsMutex.RUnlock()
fake.pingMutex.RLock()
defer fake.pingMutex.RUnlock()
fake.connectMutex.RLock()
defer fake.connectMutex.RUnlock()
fake.disconnectMutex.RLock()
defer fake.disconnectMutex.RUnlock()
fake.publishMutex.RLock()
defer fake.publishMutex.RUnlock()
fake.publishWithReplyToMutex.RLock()
defer fake.publishWithReplyToMutex.RUnlock()
fake.subscribeMutex.RLock()
defer fake.subscribeMutex.RUnlock()
fake.subscribeWithQueueMutex.RLock()
defer fake.subscribeWithQueueMutex.RUnlock()
fake.unsubscribeMutex.RLock()
defer fake.unsubscribeMutex.RUnlock()
fake.unsubscribeAllMutex.RLock()
defer fake.unsubscribeAllMutex.RUnlock()
fake.beforeConnectCallbackMutex.RLock()
defer fake.beforeConnectCallbackMutex.RUnlock()
return fake.invocations
}
func (fake *FakeNATSClient) recordInvocation(key string, args []interface{}) {
fake.invocationsMutex.Lock()
defer fake.invocationsMutex.Unlock()
if fake.invocations == nil {
fake.invocations = map[string][][]interface{}{}
}
if fake.invocations[key] == nil {
fake.invocations[key] = [][]interface{}{}
}
fake.invocations[key] = append(fake.invocations[key], args)
}
var _ yagnats.NATSClient = new(FakeNATSClient)