-
Notifications
You must be signed in to change notification settings - Fork 2
/
record_exporter_client_mock.go
287 lines (239 loc) · 10.6 KB
/
record_exporter_client_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
package mock
// Code generated by http://github.com/gojuno/minimock (3.0.6). DO NOT EDIT.
import (
context "context"
"sync"
mm_atomic "sync/atomic"
mm_time "time"
_ "github.com/gogo/protobuf/gogoproto"
"github.com/gojuno/minimock/v3"
mm_exporter "github.com/insolar/insolar/ledger/heavy/exporter"
grpc "google.golang.org/grpc"
)
// RecordExporterClientMock implements exporter.RecordExporterClient
type RecordExporterClientMock struct {
t minimock.Tester
funcExport func(ctx context.Context, in *mm_exporter.GetRecords, opts ...grpc.CallOption) (r1 mm_exporter.RecordExporter_ExportClient, err error)
inspectFuncExport func(ctx context.Context, in *mm_exporter.GetRecords, opts ...grpc.CallOption)
afterExportCounter uint64
beforeExportCounter uint64
ExportMock mRecordExporterClientMockExport
}
// NewRecordExporterClientMock returns a mock for exporter.RecordExporterClient
func NewRecordExporterClientMock(t minimock.Tester) *RecordExporterClientMock {
m := &RecordExporterClientMock{t: t}
if controller, ok := t.(minimock.MockController); ok {
controller.RegisterMocker(m)
}
m.ExportMock = mRecordExporterClientMockExport{mock: m}
m.ExportMock.callArgs = []*RecordExporterClientMockExportParams{}
return m
}
type mRecordExporterClientMockExport struct {
mock *RecordExporterClientMock
defaultExpectation *RecordExporterClientMockExportExpectation
expectations []*RecordExporterClientMockExportExpectation
callArgs []*RecordExporterClientMockExportParams
mutex sync.RWMutex
}
// RecordExporterClientMockExportExpectation specifies expectation struct of the RecordExporterClient.Export
type RecordExporterClientMockExportExpectation struct {
mock *RecordExporterClientMock
params *RecordExporterClientMockExportParams
results *RecordExporterClientMockExportResults
Counter uint64
}
// RecordExporterClientMockExportParams contains parameters of the RecordExporterClient.Export
type RecordExporterClientMockExportParams struct {
ctx context.Context
in *mm_exporter.GetRecords
opts []grpc.CallOption
}
// RecordExporterClientMockExportResults contains results of the RecordExporterClient.Export
type RecordExporterClientMockExportResults struct {
r1 mm_exporter.RecordExporter_ExportClient
err error
}
// Expect sets up expected params for RecordExporterClient.Export
func (mmExport *mRecordExporterClientMockExport) Expect(ctx context.Context, in *mm_exporter.GetRecords, opts ...grpc.CallOption) *mRecordExporterClientMockExport {
if mmExport.mock.funcExport != nil {
mmExport.mock.t.Fatalf("RecordExporterClientMock.Export mock is already set by Set")
}
if mmExport.defaultExpectation == nil {
mmExport.defaultExpectation = &RecordExporterClientMockExportExpectation{}
}
mmExport.defaultExpectation.params = &RecordExporterClientMockExportParams{ctx, in, opts}
for _, e := range mmExport.expectations {
if minimock.Equal(e.params, mmExport.defaultExpectation.params) {
mmExport.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmExport.defaultExpectation.params)
}
}
return mmExport
}
// Inspect accepts an inspector function that has same arguments as the RecordExporterClient.Export
func (mmExport *mRecordExporterClientMockExport) Inspect(f func(ctx context.Context, in *mm_exporter.GetRecords, opts ...grpc.CallOption)) *mRecordExporterClientMockExport {
if mmExport.mock.inspectFuncExport != nil {
mmExport.mock.t.Fatalf("Inspect function is already set for RecordExporterClientMock.Export")
}
mmExport.mock.inspectFuncExport = f
return mmExport
}
// Return sets up results that will be returned by RecordExporterClient.Export
func (mmExport *mRecordExporterClientMockExport) Return(r1 mm_exporter.RecordExporter_ExportClient, err error) *RecordExporterClientMock {
if mmExport.mock.funcExport != nil {
mmExport.mock.t.Fatalf("RecordExporterClientMock.Export mock is already set by Set")
}
if mmExport.defaultExpectation == nil {
mmExport.defaultExpectation = &RecordExporterClientMockExportExpectation{mock: mmExport.mock}
}
mmExport.defaultExpectation.results = &RecordExporterClientMockExportResults{r1, err}
return mmExport.mock
}
//Set uses given function f to mock the RecordExporterClient.Export method
func (mmExport *mRecordExporterClientMockExport) Set(f func(ctx context.Context, in *mm_exporter.GetRecords, opts ...grpc.CallOption) (r1 mm_exporter.RecordExporter_ExportClient, err error)) *RecordExporterClientMock {
if mmExport.defaultExpectation != nil {
mmExport.mock.t.Fatalf("Default expectation is already set for the RecordExporterClient.Export method")
}
if len(mmExport.expectations) > 0 {
mmExport.mock.t.Fatalf("Some expectations are already set for the RecordExporterClient.Export method")
}
mmExport.mock.funcExport = f
return mmExport.mock
}
// When sets expectation for the RecordExporterClient.Export which will trigger the result defined by the following
// Then helper
func (mmExport *mRecordExporterClientMockExport) When(ctx context.Context, in *mm_exporter.GetRecords, opts ...grpc.CallOption) *RecordExporterClientMockExportExpectation {
if mmExport.mock.funcExport != nil {
mmExport.mock.t.Fatalf("RecordExporterClientMock.Export mock is already set by Set")
}
expectation := &RecordExporterClientMockExportExpectation{
mock: mmExport.mock,
params: &RecordExporterClientMockExportParams{ctx, in, opts},
}
mmExport.expectations = append(mmExport.expectations, expectation)
return expectation
}
// Then sets up RecordExporterClient.Export return parameters for the expectation previously defined by the When method
func (e *RecordExporterClientMockExportExpectation) Then(r1 mm_exporter.RecordExporter_ExportClient, err error) *RecordExporterClientMock {
e.results = &RecordExporterClientMockExportResults{r1, err}
return e.mock
}
// Export implements exporter.RecordExporterClient
func (mmExport *RecordExporterClientMock) Export(ctx context.Context, in *mm_exporter.GetRecords, opts ...grpc.CallOption) (r1 mm_exporter.RecordExporter_ExportClient, err error) {
mm_atomic.AddUint64(&mmExport.beforeExportCounter, 1)
defer mm_atomic.AddUint64(&mmExport.afterExportCounter, 1)
if mmExport.inspectFuncExport != nil {
mmExport.inspectFuncExport(ctx, in, opts...)
}
mm_params := &RecordExporterClientMockExportParams{ctx, in, opts}
// Record call args
mmExport.ExportMock.mutex.Lock()
mmExport.ExportMock.callArgs = append(mmExport.ExportMock.callArgs, mm_params)
mmExport.ExportMock.mutex.Unlock()
for _, e := range mmExport.ExportMock.expectations {
if minimock.Equal(e.params, mm_params) {
mm_atomic.AddUint64(&e.Counter, 1)
return e.results.r1, e.results.err
}
}
if mmExport.ExportMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmExport.ExportMock.defaultExpectation.Counter, 1)
mm_want := mmExport.ExportMock.defaultExpectation.params
mm_got := RecordExporterClientMockExportParams{ctx, in, opts}
if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
mmExport.t.Errorf("RecordExporterClientMock.Export got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
}
mm_results := mmExport.ExportMock.defaultExpectation.results
if mm_results == nil {
mmExport.t.Fatal("No results are set for the RecordExporterClientMock.Export")
}
return (*mm_results).r1, (*mm_results).err
}
if mmExport.funcExport != nil {
return mmExport.funcExport(ctx, in, opts...)
}
mmExport.t.Fatalf("Unexpected call to RecordExporterClientMock.Export. %v %v %v", ctx, in, opts)
return
}
// ExportAfterCounter returns a count of finished RecordExporterClientMock.Export invocations
func (mmExport *RecordExporterClientMock) ExportAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmExport.afterExportCounter)
}
// ExportBeforeCounter returns a count of RecordExporterClientMock.Export invocations
func (mmExport *RecordExporterClientMock) ExportBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmExport.beforeExportCounter)
}
// Calls returns a list of arguments used in each call to RecordExporterClientMock.Export.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmExport *mRecordExporterClientMockExport) Calls() []*RecordExporterClientMockExportParams {
mmExport.mutex.RLock()
argCopy := make([]*RecordExporterClientMockExportParams, len(mmExport.callArgs))
copy(argCopy, mmExport.callArgs)
mmExport.mutex.RUnlock()
return argCopy
}
// MinimockExportDone returns true if the count of the Export invocations corresponds
// the number of defined expectations
func (m *RecordExporterClientMock) MinimockExportDone() bool {
for _, e := range m.ExportMock.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.ExportMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterExportCounter) < 1 {
return false
}
// if func was set then invocations count should be greater than zero
if m.funcExport != nil && mm_atomic.LoadUint64(&m.afterExportCounter) < 1 {
return false
}
return true
}
// MinimockExportInspect logs each unmet expectation
func (m *RecordExporterClientMock) MinimockExportInspect() {
for _, e := range m.ExportMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Errorf("Expected call to RecordExporterClientMock.Export with params: %#v", *e.params)
}
}
// if default expectation was set then invocations count should be greater than zero
if m.ExportMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterExportCounter) < 1 {
if m.ExportMock.defaultExpectation.params == nil {
m.t.Error("Expected call to RecordExporterClientMock.Export")
} else {
m.t.Errorf("Expected call to RecordExporterClientMock.Export with params: %#v", *m.ExportMock.defaultExpectation.params)
}
}
// if func was set then invocations count should be greater than zero
if m.funcExport != nil && mm_atomic.LoadUint64(&m.afterExportCounter) < 1 {
m.t.Error("Expected call to RecordExporterClientMock.Export")
}
}
// MinimockFinish checks that all mocked methods have been called the expected number of times
func (m *RecordExporterClientMock) MinimockFinish() {
if !m.minimockDone() {
m.MinimockExportInspect()
m.t.FailNow()
}
}
// MinimockWait waits for all mocked methods to be called the expected number of times
func (m *RecordExporterClientMock) 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 *RecordExporterClientMock) minimockDone() bool {
done := true
return done &&
m.MinimockExportDone()
}