-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmock_kvclientpool_test.go
More file actions
244 lines (225 loc) · 6.76 KB
/
mock_kvclientpool_test.go
File metadata and controls
244 lines (225 loc) · 6.76 KB
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
// Code generated by moq; DO NOT EDIT.
// github.com/matryer/moq
package gocbcorex
import (
"context"
"sync"
)
// Ensure, that KvClientPoolMock does implement KvClientPool.
// If this is not the case, regenerate this file with moq.
var _ KvClientPool = &KvClientPoolMock{}
// KvClientPoolMock is a mock implementation of KvClientPool.
//
// func TestSomethingThatUsesKvClientPool(t *testing.T) {
//
// // make and configure a mocked KvClientPool
// mockedKvClientPool := &KvClientPoolMock{
// CloseFunc: func() error {
// panic("mock out the Close method")
// },
// GetClientFunc: func(ctx context.Context) (KvClient, error) {
// panic("mock out the GetClient method")
// },
// UpdateAuthFunc: func(newAuth KvClientAuth) {
// panic("mock out the UpdateAuth method")
// },
// UpdateSelectedBucketFunc: func(newBucket string) {
// panic("mock out the UpdateSelectedBucket method")
// },
// UpdateTargetFunc: func(newTarget KvTarget) {
// panic("mock out the UpdateTarget method")
// },
// }
//
// // use mockedKvClientPool in code that requires KvClientPool
// // and then make assertions.
//
// }
type KvClientPoolMock struct {
// CloseFunc mocks the Close method.
CloseFunc func() error
// GetClientFunc mocks the GetClient method.
GetClientFunc func(ctx context.Context) (KvClient, error)
// UpdateAuthFunc mocks the UpdateAuth method.
UpdateAuthFunc func(newAuth KvClientAuth)
// UpdateSelectedBucketFunc mocks the UpdateSelectedBucket method.
UpdateSelectedBucketFunc func(newBucket string)
// UpdateTargetFunc mocks the UpdateTarget method.
UpdateTargetFunc func(newTarget KvTarget)
// calls tracks calls to the methods.
calls struct {
// Close holds details about calls to the Close method.
Close []struct {
}
// GetClient holds details about calls to the GetClient method.
GetClient []struct {
// Ctx is the ctx argument value.
Ctx context.Context
}
// UpdateAuth holds details about calls to the UpdateAuth method.
UpdateAuth []struct {
// NewAuth is the newAuth argument value.
NewAuth KvClientAuth
}
// UpdateSelectedBucket holds details about calls to the UpdateSelectedBucket method.
UpdateSelectedBucket []struct {
// NewBucket is the newBucket argument value.
NewBucket string
}
// UpdateTarget holds details about calls to the UpdateTarget method.
UpdateTarget []struct {
// NewTarget is the newTarget argument value.
NewTarget KvTarget
}
}
lockClose sync.RWMutex
lockGetClient sync.RWMutex
lockUpdateAuth sync.RWMutex
lockUpdateSelectedBucket sync.RWMutex
lockUpdateTarget sync.RWMutex
}
// Close calls CloseFunc.
func (mock *KvClientPoolMock) Close() error {
if mock.CloseFunc == nil {
panic("KvClientPoolMock.CloseFunc: method is nil but KvClientPool.Close was just called")
}
callInfo := struct {
}{}
mock.lockClose.Lock()
mock.calls.Close = append(mock.calls.Close, callInfo)
mock.lockClose.Unlock()
return mock.CloseFunc()
}
// CloseCalls gets all the calls that were made to Close.
// Check the length with:
//
// len(mockedKvClientPool.CloseCalls())
func (mock *KvClientPoolMock) CloseCalls() []struct {
} {
var calls []struct {
}
mock.lockClose.RLock()
calls = mock.calls.Close
mock.lockClose.RUnlock()
return calls
}
// GetClient calls GetClientFunc.
func (mock *KvClientPoolMock) GetClient(ctx context.Context) (KvClient, error) {
if mock.GetClientFunc == nil {
panic("KvClientPoolMock.GetClientFunc: method is nil but KvClientPool.GetClient was just called")
}
callInfo := struct {
Ctx context.Context
}{
Ctx: ctx,
}
mock.lockGetClient.Lock()
mock.calls.GetClient = append(mock.calls.GetClient, callInfo)
mock.lockGetClient.Unlock()
return mock.GetClientFunc(ctx)
}
// GetClientCalls gets all the calls that were made to GetClient.
// Check the length with:
//
// len(mockedKvClientPool.GetClientCalls())
func (mock *KvClientPoolMock) GetClientCalls() []struct {
Ctx context.Context
} {
var calls []struct {
Ctx context.Context
}
mock.lockGetClient.RLock()
calls = mock.calls.GetClient
mock.lockGetClient.RUnlock()
return calls
}
// UpdateAuth calls UpdateAuthFunc.
func (mock *KvClientPoolMock) UpdateAuth(newAuth KvClientAuth) {
if mock.UpdateAuthFunc == nil {
panic("KvClientPoolMock.UpdateAuthFunc: method is nil but KvClientPool.UpdateAuth was just called")
}
callInfo := struct {
NewAuth KvClientAuth
}{
NewAuth: newAuth,
}
mock.lockUpdateAuth.Lock()
mock.calls.UpdateAuth = append(mock.calls.UpdateAuth, callInfo)
mock.lockUpdateAuth.Unlock()
mock.UpdateAuthFunc(newAuth)
}
// UpdateAuthCalls gets all the calls that were made to UpdateAuth.
// Check the length with:
//
// len(mockedKvClientPool.UpdateAuthCalls())
func (mock *KvClientPoolMock) UpdateAuthCalls() []struct {
NewAuth KvClientAuth
} {
var calls []struct {
NewAuth KvClientAuth
}
mock.lockUpdateAuth.RLock()
calls = mock.calls.UpdateAuth
mock.lockUpdateAuth.RUnlock()
return calls
}
// UpdateSelectedBucket calls UpdateSelectedBucketFunc.
func (mock *KvClientPoolMock) UpdateSelectedBucket(newBucket string) {
if mock.UpdateSelectedBucketFunc == nil {
panic("KvClientPoolMock.UpdateSelectedBucketFunc: method is nil but KvClientPool.UpdateSelectedBucket was just called")
}
callInfo := struct {
NewBucket string
}{
NewBucket: newBucket,
}
mock.lockUpdateSelectedBucket.Lock()
mock.calls.UpdateSelectedBucket = append(mock.calls.UpdateSelectedBucket, callInfo)
mock.lockUpdateSelectedBucket.Unlock()
mock.UpdateSelectedBucketFunc(newBucket)
}
// UpdateSelectedBucketCalls gets all the calls that were made to UpdateSelectedBucket.
// Check the length with:
//
// len(mockedKvClientPool.UpdateSelectedBucketCalls())
func (mock *KvClientPoolMock) UpdateSelectedBucketCalls() []struct {
NewBucket string
} {
var calls []struct {
NewBucket string
}
mock.lockUpdateSelectedBucket.RLock()
calls = mock.calls.UpdateSelectedBucket
mock.lockUpdateSelectedBucket.RUnlock()
return calls
}
// UpdateTarget calls UpdateTargetFunc.
func (mock *KvClientPoolMock) UpdateTarget(newTarget KvTarget) {
if mock.UpdateTargetFunc == nil {
panic("KvClientPoolMock.UpdateTargetFunc: method is nil but KvClientPool.UpdateTarget was just called")
}
callInfo := struct {
NewTarget KvTarget
}{
NewTarget: newTarget,
}
mock.lockUpdateTarget.Lock()
mock.calls.UpdateTarget = append(mock.calls.UpdateTarget, callInfo)
mock.lockUpdateTarget.Unlock()
mock.UpdateTargetFunc(newTarget)
}
// UpdateTargetCalls gets all the calls that were made to UpdateTarget.
// Check the length with:
//
// len(mockedKvClientPool.UpdateTargetCalls())
func (mock *KvClientPoolMock) UpdateTargetCalls() []struct {
NewTarget KvTarget
} {
var calls []struct {
NewTarget KvTarget
}
mock.lockUpdateTarget.RLock()
calls = mock.calls.UpdateTarget
mock.lockUpdateTarget.RUnlock()
return calls
}