-
Notifications
You must be signed in to change notification settings - Fork 4
/
writeable_mock.go
582 lines (476 loc) · 20.6 KB
/
writeable_mock.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
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
package bundle
// Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT.
import (
"sync"
mm_atomic "sync/atomic"
mm_time "time"
"github.com/gojuno/minimock/v3"
"github.com/insolar/assured-ledger/ledger-core/ledger"
)
// WriteableMock implements Writeable
type WriteableMock struct {
t minimock.Tester
funcApplyRollback func()
inspectFuncApplyRollback func()
afterApplyRollbackCounter uint64
beforeApplyRollbackCounter uint64
ApplyRollbackMock mWriteableMockApplyRollback
funcApplyWrite func() (da1 []ledger.DirectoryIndex, err error)
inspectFuncApplyWrite func()
afterApplyWriteCounter uint64
beforeApplyWriteCounter uint64
ApplyWriteMock mWriteableMockApplyWrite
funcPrepareWrite func(s1 Snapshot) (err error)
inspectFuncPrepareWrite func(s1 Snapshot)
afterPrepareWriteCounter uint64
beforePrepareWriteCounter uint64
PrepareWriteMock mWriteableMockPrepareWrite
}
// NewWriteableMock returns a mock for Writeable
func NewWriteableMock(t minimock.Tester) *WriteableMock {
m := &WriteableMock{t: t}
if controller, ok := t.(minimock.MockController); ok {
controller.RegisterMocker(m)
}
m.ApplyRollbackMock = mWriteableMockApplyRollback{mock: m}
m.ApplyWriteMock = mWriteableMockApplyWrite{mock: m}
m.PrepareWriteMock = mWriteableMockPrepareWrite{mock: m}
m.PrepareWriteMock.callArgs = []*WriteableMockPrepareWriteParams{}
return m
}
type mWriteableMockApplyRollback struct {
mock *WriteableMock
defaultExpectation *WriteableMockApplyRollbackExpectation
expectations []*WriteableMockApplyRollbackExpectation
}
// WriteableMockApplyRollbackExpectation specifies expectation struct of the Writeable.ApplyRollback
type WriteableMockApplyRollbackExpectation struct {
mock *WriteableMock
Counter uint64
}
// Expect sets up expected params for Writeable.ApplyRollback
func (mmApplyRollback *mWriteableMockApplyRollback) Expect() *mWriteableMockApplyRollback {
if mmApplyRollback.mock.funcApplyRollback != nil {
mmApplyRollback.mock.t.Fatalf("WriteableMock.ApplyRollback mock is already set by Set")
}
if mmApplyRollback.defaultExpectation == nil {
mmApplyRollback.defaultExpectation = &WriteableMockApplyRollbackExpectation{}
}
return mmApplyRollback
}
// Inspect accepts an inspector function that has same arguments as the Writeable.ApplyRollback
func (mmApplyRollback *mWriteableMockApplyRollback) Inspect(f func()) *mWriteableMockApplyRollback {
if mmApplyRollback.mock.inspectFuncApplyRollback != nil {
mmApplyRollback.mock.t.Fatalf("Inspect function is already set for WriteableMock.ApplyRollback")
}
mmApplyRollback.mock.inspectFuncApplyRollback = f
return mmApplyRollback
}
// Return sets up results that will be returned by Writeable.ApplyRollback
func (mmApplyRollback *mWriteableMockApplyRollback) Return() *WriteableMock {
if mmApplyRollback.mock.funcApplyRollback != nil {
mmApplyRollback.mock.t.Fatalf("WriteableMock.ApplyRollback mock is already set by Set")
}
if mmApplyRollback.defaultExpectation == nil {
mmApplyRollback.defaultExpectation = &WriteableMockApplyRollbackExpectation{mock: mmApplyRollback.mock}
}
return mmApplyRollback.mock
}
//Set uses given function f to mock the Writeable.ApplyRollback method
func (mmApplyRollback *mWriteableMockApplyRollback) Set(f func()) *WriteableMock {
if mmApplyRollback.defaultExpectation != nil {
mmApplyRollback.mock.t.Fatalf("Default expectation is already set for the Writeable.ApplyRollback method")
}
if len(mmApplyRollback.expectations) > 0 {
mmApplyRollback.mock.t.Fatalf("Some expectations are already set for the Writeable.ApplyRollback method")
}
mmApplyRollback.mock.funcApplyRollback = f
return mmApplyRollback.mock
}
// ApplyRollback implements Writeable
func (mmApplyRollback *WriteableMock) ApplyRollback() {
mm_atomic.AddUint64(&mmApplyRollback.beforeApplyRollbackCounter, 1)
defer mm_atomic.AddUint64(&mmApplyRollback.afterApplyRollbackCounter, 1)
if mmApplyRollback.inspectFuncApplyRollback != nil {
mmApplyRollback.inspectFuncApplyRollback()
}
if mmApplyRollback.ApplyRollbackMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmApplyRollback.ApplyRollbackMock.defaultExpectation.Counter, 1)
return
}
if mmApplyRollback.funcApplyRollback != nil {
mmApplyRollback.funcApplyRollback()
return
}
mmApplyRollback.t.Fatalf("Unexpected call to WriteableMock.ApplyRollback.")
}
// ApplyRollbackAfterCounter returns a count of finished WriteableMock.ApplyRollback invocations
func (mmApplyRollback *WriteableMock) ApplyRollbackAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmApplyRollback.afterApplyRollbackCounter)
}
// ApplyRollbackBeforeCounter returns a count of WriteableMock.ApplyRollback invocations
func (mmApplyRollback *WriteableMock) ApplyRollbackBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmApplyRollback.beforeApplyRollbackCounter)
}
// MinimockApplyRollbackDone returns true if the count of the ApplyRollback invocations corresponds
// the number of defined expectations
func (m *WriteableMock) MinimockApplyRollbackDone() bool {
for _, e := range m.ApplyRollbackMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
return false
}
}
// if default expectation was set then invocations count should be greater than zero
if m.ApplyRollbackMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterApplyRollbackCounter) < 1 {
return false
}
// if func was set then invocations count should be greater than zero
if m.funcApplyRollback != nil && mm_atomic.LoadUint64(&m.afterApplyRollbackCounter) < 1 {
return false
}
return true
}
// MinimockApplyRollbackInspect logs each unmet expectation
func (m *WriteableMock) MinimockApplyRollbackInspect() {
for _, e := range m.ApplyRollbackMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Error("Expected call to WriteableMock.ApplyRollback")
}
}
// if default expectation was set then invocations count should be greater than zero
if m.ApplyRollbackMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterApplyRollbackCounter) < 1 {
m.t.Error("Expected call to WriteableMock.ApplyRollback")
}
// if func was set then invocations count should be greater than zero
if m.funcApplyRollback != nil && mm_atomic.LoadUint64(&m.afterApplyRollbackCounter) < 1 {
m.t.Error("Expected call to WriteableMock.ApplyRollback")
}
}
type mWriteableMockApplyWrite struct {
mock *WriteableMock
defaultExpectation *WriteableMockApplyWriteExpectation
expectations []*WriteableMockApplyWriteExpectation
}
// WriteableMockApplyWriteExpectation specifies expectation struct of the Writeable.ApplyWrite
type WriteableMockApplyWriteExpectation struct {
mock *WriteableMock
results *WriteableMockApplyWriteResults
Counter uint64
}
// WriteableMockApplyWriteResults contains results of the Writeable.ApplyWrite
type WriteableMockApplyWriteResults struct {
da1 []ledger.DirectoryIndex
err error
}
// Expect sets up expected params for Writeable.ApplyWrite
func (mmApplyWrite *mWriteableMockApplyWrite) Expect() *mWriteableMockApplyWrite {
if mmApplyWrite.mock.funcApplyWrite != nil {
mmApplyWrite.mock.t.Fatalf("WriteableMock.ApplyWrite mock is already set by Set")
}
if mmApplyWrite.defaultExpectation == nil {
mmApplyWrite.defaultExpectation = &WriteableMockApplyWriteExpectation{}
}
return mmApplyWrite
}
// Inspect accepts an inspector function that has same arguments as the Writeable.ApplyWrite
func (mmApplyWrite *mWriteableMockApplyWrite) Inspect(f func()) *mWriteableMockApplyWrite {
if mmApplyWrite.mock.inspectFuncApplyWrite != nil {
mmApplyWrite.mock.t.Fatalf("Inspect function is already set for WriteableMock.ApplyWrite")
}
mmApplyWrite.mock.inspectFuncApplyWrite = f
return mmApplyWrite
}
// Return sets up results that will be returned by Writeable.ApplyWrite
func (mmApplyWrite *mWriteableMockApplyWrite) Return(da1 []ledger.DirectoryIndex, err error) *WriteableMock {
if mmApplyWrite.mock.funcApplyWrite != nil {
mmApplyWrite.mock.t.Fatalf("WriteableMock.ApplyWrite mock is already set by Set")
}
if mmApplyWrite.defaultExpectation == nil {
mmApplyWrite.defaultExpectation = &WriteableMockApplyWriteExpectation{mock: mmApplyWrite.mock}
}
mmApplyWrite.defaultExpectation.results = &WriteableMockApplyWriteResults{da1, err}
return mmApplyWrite.mock
}
//Set uses given function f to mock the Writeable.ApplyWrite method
func (mmApplyWrite *mWriteableMockApplyWrite) Set(f func() (da1 []ledger.DirectoryIndex, err error)) *WriteableMock {
if mmApplyWrite.defaultExpectation != nil {
mmApplyWrite.mock.t.Fatalf("Default expectation is already set for the Writeable.ApplyWrite method")
}
if len(mmApplyWrite.expectations) > 0 {
mmApplyWrite.mock.t.Fatalf("Some expectations are already set for the Writeable.ApplyWrite method")
}
mmApplyWrite.mock.funcApplyWrite = f
return mmApplyWrite.mock
}
// ApplyWrite implements Writeable
func (mmApplyWrite *WriteableMock) ApplyWrite() (da1 []ledger.DirectoryIndex, err error) {
mm_atomic.AddUint64(&mmApplyWrite.beforeApplyWriteCounter, 1)
defer mm_atomic.AddUint64(&mmApplyWrite.afterApplyWriteCounter, 1)
if mmApplyWrite.inspectFuncApplyWrite != nil {
mmApplyWrite.inspectFuncApplyWrite()
}
if mmApplyWrite.ApplyWriteMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmApplyWrite.ApplyWriteMock.defaultExpectation.Counter, 1)
mm_results := mmApplyWrite.ApplyWriteMock.defaultExpectation.results
if mm_results == nil {
mmApplyWrite.t.Fatal("No results are set for the WriteableMock.ApplyWrite")
}
return (*mm_results).da1, (*mm_results).err
}
if mmApplyWrite.funcApplyWrite != nil {
return mmApplyWrite.funcApplyWrite()
}
mmApplyWrite.t.Fatalf("Unexpected call to WriteableMock.ApplyWrite.")
return
}
// ApplyWriteAfterCounter returns a count of finished WriteableMock.ApplyWrite invocations
func (mmApplyWrite *WriteableMock) ApplyWriteAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmApplyWrite.afterApplyWriteCounter)
}
// ApplyWriteBeforeCounter returns a count of WriteableMock.ApplyWrite invocations
func (mmApplyWrite *WriteableMock) ApplyWriteBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmApplyWrite.beforeApplyWriteCounter)
}
// MinimockApplyWriteDone returns true if the count of the ApplyWrite invocations corresponds
// the number of defined expectations
func (m *WriteableMock) MinimockApplyWriteDone() bool {
for _, e := range m.ApplyWriteMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
return false
}
}
// if default expectation was set then invocations count should be greater than zero
if m.ApplyWriteMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterApplyWriteCounter) < 1 {
return false
}
// if func was set then invocations count should be greater than zero
if m.funcApplyWrite != nil && mm_atomic.LoadUint64(&m.afterApplyWriteCounter) < 1 {
return false
}
return true
}
// MinimockApplyWriteInspect logs each unmet expectation
func (m *WriteableMock) MinimockApplyWriteInspect() {
for _, e := range m.ApplyWriteMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Error("Expected call to WriteableMock.ApplyWrite")
}
}
// if default expectation was set then invocations count should be greater than zero
if m.ApplyWriteMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterApplyWriteCounter) < 1 {
m.t.Error("Expected call to WriteableMock.ApplyWrite")
}
// if func was set then invocations count should be greater than zero
if m.funcApplyWrite != nil && mm_atomic.LoadUint64(&m.afterApplyWriteCounter) < 1 {
m.t.Error("Expected call to WriteableMock.ApplyWrite")
}
}
type mWriteableMockPrepareWrite struct {
mock *WriteableMock
defaultExpectation *WriteableMockPrepareWriteExpectation
expectations []*WriteableMockPrepareWriteExpectation
callArgs []*WriteableMockPrepareWriteParams
mutex sync.RWMutex
}
// WriteableMockPrepareWriteExpectation specifies expectation struct of the Writeable.PrepareWrite
type WriteableMockPrepareWriteExpectation struct {
mock *WriteableMock
params *WriteableMockPrepareWriteParams
results *WriteableMockPrepareWriteResults
Counter uint64
}
// WriteableMockPrepareWriteParams contains parameters of the Writeable.PrepareWrite
type WriteableMockPrepareWriteParams struct {
s1 Snapshot
}
// WriteableMockPrepareWriteResults contains results of the Writeable.PrepareWrite
type WriteableMockPrepareWriteResults struct {
err error
}
// Expect sets up expected params for Writeable.PrepareWrite
func (mmPrepareWrite *mWriteableMockPrepareWrite) Expect(s1 Snapshot) *mWriteableMockPrepareWrite {
if mmPrepareWrite.mock.funcPrepareWrite != nil {
mmPrepareWrite.mock.t.Fatalf("WriteableMock.PrepareWrite mock is already set by Set")
}
if mmPrepareWrite.defaultExpectation == nil {
mmPrepareWrite.defaultExpectation = &WriteableMockPrepareWriteExpectation{}
}
mmPrepareWrite.defaultExpectation.params = &WriteableMockPrepareWriteParams{s1}
for _, e := range mmPrepareWrite.expectations {
if minimock.Equal(e.params, mmPrepareWrite.defaultExpectation.params) {
mmPrepareWrite.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmPrepareWrite.defaultExpectation.params)
}
}
return mmPrepareWrite
}
// Inspect accepts an inspector function that has same arguments as the Writeable.PrepareWrite
func (mmPrepareWrite *mWriteableMockPrepareWrite) Inspect(f func(s1 Snapshot)) *mWriteableMockPrepareWrite {
if mmPrepareWrite.mock.inspectFuncPrepareWrite != nil {
mmPrepareWrite.mock.t.Fatalf("Inspect function is already set for WriteableMock.PrepareWrite")
}
mmPrepareWrite.mock.inspectFuncPrepareWrite = f
return mmPrepareWrite
}
// Return sets up results that will be returned by Writeable.PrepareWrite
func (mmPrepareWrite *mWriteableMockPrepareWrite) Return(err error) *WriteableMock {
if mmPrepareWrite.mock.funcPrepareWrite != nil {
mmPrepareWrite.mock.t.Fatalf("WriteableMock.PrepareWrite mock is already set by Set")
}
if mmPrepareWrite.defaultExpectation == nil {
mmPrepareWrite.defaultExpectation = &WriteableMockPrepareWriteExpectation{mock: mmPrepareWrite.mock}
}
mmPrepareWrite.defaultExpectation.results = &WriteableMockPrepareWriteResults{err}
return mmPrepareWrite.mock
}
//Set uses given function f to mock the Writeable.PrepareWrite method
func (mmPrepareWrite *mWriteableMockPrepareWrite) Set(f func(s1 Snapshot) (err error)) *WriteableMock {
if mmPrepareWrite.defaultExpectation != nil {
mmPrepareWrite.mock.t.Fatalf("Default expectation is already set for the Writeable.PrepareWrite method")
}
if len(mmPrepareWrite.expectations) > 0 {
mmPrepareWrite.mock.t.Fatalf("Some expectations are already set for the Writeable.PrepareWrite method")
}
mmPrepareWrite.mock.funcPrepareWrite = f
return mmPrepareWrite.mock
}
// When sets expectation for the Writeable.PrepareWrite which will trigger the result defined by the following
// Then helper
func (mmPrepareWrite *mWriteableMockPrepareWrite) When(s1 Snapshot) *WriteableMockPrepareWriteExpectation {
if mmPrepareWrite.mock.funcPrepareWrite != nil {
mmPrepareWrite.mock.t.Fatalf("WriteableMock.PrepareWrite mock is already set by Set")
}
expectation := &WriteableMockPrepareWriteExpectation{
mock: mmPrepareWrite.mock,
params: &WriteableMockPrepareWriteParams{s1},
}
mmPrepareWrite.expectations = append(mmPrepareWrite.expectations, expectation)
return expectation
}
// Then sets up Writeable.PrepareWrite return parameters for the expectation previously defined by the When method
func (e *WriteableMockPrepareWriteExpectation) Then(err error) *WriteableMock {
e.results = &WriteableMockPrepareWriteResults{err}
return e.mock
}
// PrepareWrite implements Writeable
func (mmPrepareWrite *WriteableMock) PrepareWrite(s1 Snapshot) (err error) {
mm_atomic.AddUint64(&mmPrepareWrite.beforePrepareWriteCounter, 1)
defer mm_atomic.AddUint64(&mmPrepareWrite.afterPrepareWriteCounter, 1)
if mmPrepareWrite.inspectFuncPrepareWrite != nil {
mmPrepareWrite.inspectFuncPrepareWrite(s1)
}
mm_params := &WriteableMockPrepareWriteParams{s1}
// Record call args
mmPrepareWrite.PrepareWriteMock.mutex.Lock()
mmPrepareWrite.PrepareWriteMock.callArgs = append(mmPrepareWrite.PrepareWriteMock.callArgs, mm_params)
mmPrepareWrite.PrepareWriteMock.mutex.Unlock()
for _, e := range mmPrepareWrite.PrepareWriteMock.expectations {
if minimock.Equal(e.params, mm_params) {
mm_atomic.AddUint64(&e.Counter, 1)
return e.results.err
}
}
if mmPrepareWrite.PrepareWriteMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmPrepareWrite.PrepareWriteMock.defaultExpectation.Counter, 1)
mm_want := mmPrepareWrite.PrepareWriteMock.defaultExpectation.params
mm_got := WriteableMockPrepareWriteParams{s1}
if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
mmPrepareWrite.t.Errorf("WriteableMock.PrepareWrite got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
}
mm_results := mmPrepareWrite.PrepareWriteMock.defaultExpectation.results
if mm_results == nil {
mmPrepareWrite.t.Fatal("No results are set for the WriteableMock.PrepareWrite")
}
return (*mm_results).err
}
if mmPrepareWrite.funcPrepareWrite != nil {
return mmPrepareWrite.funcPrepareWrite(s1)
}
mmPrepareWrite.t.Fatalf("Unexpected call to WriteableMock.PrepareWrite. %v", s1)
return
}
// PrepareWriteAfterCounter returns a count of finished WriteableMock.PrepareWrite invocations
func (mmPrepareWrite *WriteableMock) PrepareWriteAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmPrepareWrite.afterPrepareWriteCounter)
}
// PrepareWriteBeforeCounter returns a count of WriteableMock.PrepareWrite invocations
func (mmPrepareWrite *WriteableMock) PrepareWriteBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmPrepareWrite.beforePrepareWriteCounter)
}
// Calls returns a list of arguments used in each call to WriteableMock.PrepareWrite.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmPrepareWrite *mWriteableMockPrepareWrite) Calls() []*WriteableMockPrepareWriteParams {
mmPrepareWrite.mutex.RLock()
argCopy := make([]*WriteableMockPrepareWriteParams, len(mmPrepareWrite.callArgs))
copy(argCopy, mmPrepareWrite.callArgs)
mmPrepareWrite.mutex.RUnlock()
return argCopy
}
// MinimockPrepareWriteDone returns true if the count of the PrepareWrite invocations corresponds
// the number of defined expectations
func (m *WriteableMock) MinimockPrepareWriteDone() bool {
for _, e := range m.PrepareWriteMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
return false
}
}
// if default expectation was set then invocations count should be greater than zero
if m.PrepareWriteMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterPrepareWriteCounter) < 1 {
return false
}
// if func was set then invocations count should be greater than zero
if m.funcPrepareWrite != nil && mm_atomic.LoadUint64(&m.afterPrepareWriteCounter) < 1 {
return false
}
return true
}
// MinimockPrepareWriteInspect logs each unmet expectation
func (m *WriteableMock) MinimockPrepareWriteInspect() {
for _, e := range m.PrepareWriteMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Errorf("Expected call to WriteableMock.PrepareWrite with params: %#v", *e.params)
}
}
// if default expectation was set then invocations count should be greater than zero
if m.PrepareWriteMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterPrepareWriteCounter) < 1 {
if m.PrepareWriteMock.defaultExpectation.params == nil {
m.t.Error("Expected call to WriteableMock.PrepareWrite")
} else {
m.t.Errorf("Expected call to WriteableMock.PrepareWrite with params: %#v", *m.PrepareWriteMock.defaultExpectation.params)
}
}
// if func was set then invocations count should be greater than zero
if m.funcPrepareWrite != nil && mm_atomic.LoadUint64(&m.afterPrepareWriteCounter) < 1 {
m.t.Error("Expected call to WriteableMock.PrepareWrite")
}
}
// MinimockFinish checks that all mocked methods have been called the expected number of times
func (m *WriteableMock) MinimockFinish() {
if !m.minimockDone() {
m.MinimockApplyRollbackInspect()
m.MinimockApplyWriteInspect()
m.MinimockPrepareWriteInspect()
m.t.FailNow()
}
}
// MinimockWait waits for all mocked methods to be called the expected number of times
func (m *WriteableMock) MinimockWait(timeout mm_time.Duration) {
timeoutCh := mm_time.After(timeout)
for {
if m.minimockDone() {
return
}
select {
case <-timeoutCh:
m.MinimockFinish()
return
case <-mm_time.After(10 * mm_time.Millisecond):
}
}
}
func (m *WriteableMock) minimockDone() bool {
done := true
return done &&
m.MinimockApplyRollbackDone() &&
m.MinimockApplyWriteDone() &&
m.MinimockPrepareWriteDone()
}