/
generic_inline_with_many_options.go
254 lines (205 loc) · 8.96 KB
/
generic_inline_with_many_options.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
package tests
// Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT.
//go:generate minimock -i github.com/gojuno/minimock/v3/tests.genericInlineUnionWithManyTypes -o generic_inline_with_many_options.go -n GenericInlineUnionWithManyTypesMock
import (
"sync"
mm_atomic "sync/atomic"
mm_time "time"
"github.com/gojuno/minimock/v3"
)
// GenericInlineUnionWithManyTypesMock implements genericInlineUnionWithManyTypes
type GenericInlineUnionWithManyTypesMock[T int | float64 | string] struct {
t minimock.Tester
funcName func(t1 T)
inspectFuncName func(t1 T)
afterNameCounter uint64
beforeNameCounter uint64
NameMock mGenericInlineUnionWithManyTypesMockName[T]
}
// NewGenericInlineUnionWithManyTypesMock returns a mock for genericInlineUnionWithManyTypes
func NewGenericInlineUnionWithManyTypesMock[T int | float64 | string](t minimock.Tester) *GenericInlineUnionWithManyTypesMock[T] {
m := &GenericInlineUnionWithManyTypesMock[T]{t: t}
if controller, ok := t.(minimock.MockController); ok {
controller.RegisterMocker(m)
}
m.NameMock = mGenericInlineUnionWithManyTypesMockName[T]{mock: m}
m.NameMock.callArgs = []*GenericInlineUnionWithManyTypesMockNameParams[T]{}
return m
}
type mGenericInlineUnionWithManyTypesMockName[T int | float64 | string] struct {
mock *GenericInlineUnionWithManyTypesMock[T]
defaultExpectation *GenericInlineUnionWithManyTypesMockNameExpectation[T]
expectations []*GenericInlineUnionWithManyTypesMockNameExpectation[T]
callArgs []*GenericInlineUnionWithManyTypesMockNameParams[T]
mutex sync.RWMutex
}
// GenericInlineUnionWithManyTypesMockNameExpectation specifies expectation struct of the genericInlineUnionWithManyTypes.Name
type GenericInlineUnionWithManyTypesMockNameExpectation[T int | float64 | string] struct {
mock *GenericInlineUnionWithManyTypesMock[T]
params *GenericInlineUnionWithManyTypesMockNameParams[T]
Counter uint64
}
// GenericInlineUnionWithManyTypesMockNameParams contains parameters of the genericInlineUnionWithManyTypes.Name
type GenericInlineUnionWithManyTypesMockNameParams[T int | float64 | string] struct {
t1 T
}
// Expect sets up expected params for genericInlineUnionWithManyTypes.Name
func (mmName *mGenericInlineUnionWithManyTypesMockName[T]) Expect(t1 T) *mGenericInlineUnionWithManyTypesMockName[T] {
if mmName.mock.funcName != nil {
mmName.mock.t.Fatalf("GenericInlineUnionWithManyTypesMock.Name mock is already set by Set")
}
if mmName.defaultExpectation == nil {
mmName.defaultExpectation = &GenericInlineUnionWithManyTypesMockNameExpectation[T]{}
}
mmName.defaultExpectation.params = &GenericInlineUnionWithManyTypesMockNameParams[T]{t1}
for _, e := range mmName.expectations {
if minimock.Equal(e.params, mmName.defaultExpectation.params) {
mmName.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmName.defaultExpectation.params)
}
}
return mmName
}
// Inspect accepts an inspector function that has same arguments as the genericInlineUnionWithManyTypes.Name
func (mmName *mGenericInlineUnionWithManyTypesMockName[T]) Inspect(f func(t1 T)) *mGenericInlineUnionWithManyTypesMockName[T] {
if mmName.mock.inspectFuncName != nil {
mmName.mock.t.Fatalf("Inspect function is already set for GenericInlineUnionWithManyTypesMock.Name")
}
mmName.mock.inspectFuncName = f
return mmName
}
// Return sets up results that will be returned by genericInlineUnionWithManyTypes.Name
func (mmName *mGenericInlineUnionWithManyTypesMockName[T]) Return() *GenericInlineUnionWithManyTypesMock[T] {
if mmName.mock.funcName != nil {
mmName.mock.t.Fatalf("GenericInlineUnionWithManyTypesMock.Name mock is already set by Set")
}
if mmName.defaultExpectation == nil {
mmName.defaultExpectation = &GenericInlineUnionWithManyTypesMockNameExpectation[T]{mock: mmName.mock}
}
return mmName.mock
}
// Set uses given function f to mock the genericInlineUnionWithManyTypes.Name method
func (mmName *mGenericInlineUnionWithManyTypesMockName[T]) Set(f func(t1 T)) *GenericInlineUnionWithManyTypesMock[T] {
if mmName.defaultExpectation != nil {
mmName.mock.t.Fatalf("Default expectation is already set for the genericInlineUnionWithManyTypes.Name method")
}
if len(mmName.expectations) > 0 {
mmName.mock.t.Fatalf("Some expectations are already set for the genericInlineUnionWithManyTypes.Name method")
}
mmName.mock.funcName = f
return mmName.mock
}
// Name implements genericInlineUnionWithManyTypes
func (mmName *GenericInlineUnionWithManyTypesMock[T]) Name(t1 T) {
mm_atomic.AddUint64(&mmName.beforeNameCounter, 1)
defer mm_atomic.AddUint64(&mmName.afterNameCounter, 1)
if mmName.inspectFuncName != nil {
mmName.inspectFuncName(t1)
}
mm_params := GenericInlineUnionWithManyTypesMockNameParams[T]{t1}
// Record call args
mmName.NameMock.mutex.Lock()
mmName.NameMock.callArgs = append(mmName.NameMock.callArgs, &mm_params)
mmName.NameMock.mutex.Unlock()
for _, e := range mmName.NameMock.expectations {
if minimock.Equal(*e.params, mm_params) {
mm_atomic.AddUint64(&e.Counter, 1)
return
}
}
if mmName.NameMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmName.NameMock.defaultExpectation.Counter, 1)
mm_want := mmName.NameMock.defaultExpectation.params
mm_got := GenericInlineUnionWithManyTypesMockNameParams[T]{t1}
if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
mmName.t.Errorf("GenericInlineUnionWithManyTypesMock.Name got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
}
return
}
if mmName.funcName != nil {
mmName.funcName(t1)
return
}
mmName.t.Fatalf("Unexpected call to GenericInlineUnionWithManyTypesMock.Name. %v", t1)
}
// NameAfterCounter returns a count of finished GenericInlineUnionWithManyTypesMock.Name invocations
func (mmName *GenericInlineUnionWithManyTypesMock[T]) NameAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmName.afterNameCounter)
}
// NameBeforeCounter returns a count of GenericInlineUnionWithManyTypesMock.Name invocations
func (mmName *GenericInlineUnionWithManyTypesMock[T]) NameBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmName.beforeNameCounter)
}
// Calls returns a list of arguments used in each call to GenericInlineUnionWithManyTypesMock.Name.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmName *mGenericInlineUnionWithManyTypesMockName[T]) Calls() []*GenericInlineUnionWithManyTypesMockNameParams[T] {
mmName.mutex.RLock()
argCopy := make([]*GenericInlineUnionWithManyTypesMockNameParams[T], len(mmName.callArgs))
copy(argCopy, mmName.callArgs)
mmName.mutex.RUnlock()
return argCopy
}
// MinimockNameDone returns true if the count of the Name invocations corresponds
// the number of defined expectations
func (m *GenericInlineUnionWithManyTypesMock[T]) MinimockNameDone() bool {
for _, e := range m.NameMock.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.NameMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterNameCounter) < 1 {
return false
}
// if func was set then invocations count should be greater than zero
if m.funcName != nil && mm_atomic.LoadUint64(&m.afterNameCounter) < 1 {
return false
}
return true
}
// MinimockNameInspect logs each unmet expectation
func (m *GenericInlineUnionWithManyTypesMock[T]) MinimockNameInspect() {
for _, e := range m.NameMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Errorf("Expected call to GenericInlineUnionWithManyTypesMock.Name with params: %#v", *e.params)
}
}
// if default expectation was set then invocations count should be greater than zero
if m.NameMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterNameCounter) < 1 {
if m.NameMock.defaultExpectation.params == nil {
m.t.Error("Expected call to GenericInlineUnionWithManyTypesMock.Name")
} else {
m.t.Errorf("Expected call to GenericInlineUnionWithManyTypesMock.Name with params: %#v", *m.NameMock.defaultExpectation.params)
}
}
// if func was set then invocations count should be greater than zero
if m.funcName != nil && mm_atomic.LoadUint64(&m.afterNameCounter) < 1 {
m.t.Error("Expected call to GenericInlineUnionWithManyTypesMock.Name")
}
}
// MinimockFinish checks that all mocked methods have been called the expected number of times
func (m *GenericInlineUnionWithManyTypesMock[T]) MinimockFinish() {
if !m.minimockDone() {
m.MinimockNameInspect()
m.t.FailNow()
}
}
// MinimockWait waits for all mocked methods to be called the expected number of times
func (m *GenericInlineUnionWithManyTypesMock[T]) 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 *GenericInlineUnionWithManyTypesMock[T]) minimockDone() bool {
done := true
return done &&
m.MinimockNameDone()
}