-
Notifications
You must be signed in to change notification settings - Fork 18
/
runner_updater_moq_test.go
311 lines (286 loc) · 8.68 KB
/
runner_updater_moq_test.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
// Code generated by moq; DO NOT EDIT.
// github.com/matryer/moq
package main
import (
"sync"
"time"
)
// Ensure, that RunnerUpdaterMock does implement RunnerUpdater.
// If this is not the case, regenerate this file with moq.
var _ RunnerUpdater = &RunnerUpdaterMock{}
// RunnerUpdaterMock is a mock implementation of RunnerUpdater.
//
// func TestSomethingThatUsesRunnerUpdater(t *testing.T) {
//
// // make and configure a mocked RunnerUpdater
// mockedRunnerUpdater := &RunnerUpdaterMock{
// DoUpdateFunc: func(url string) error {
// panic("mock out the DoUpdate method")
// },
// GetLastRefreshFunc: func(file string) time.Duration {
// panic("mock out the GetLastRefresh method")
// },
// GetUpdateVersionFunc: func() (string, error) {
// panic("mock out the GetUpdateVersion method")
// },
// RestartFunc: func() int {
// panic("mock out the Restart method")
// },
// RunFunc: func() int {
// panic("mock out the Run method")
// },
// SetLastRefreshFunc: func(file string) {
// panic("mock out the SetLastRefresh method")
// },
// ShouldUpdateFunc: func() bool {
// panic("mock out the ShouldUpdate method")
// },
// }
//
// // use mockedRunnerUpdater in code that requires RunnerUpdater
// // and then make assertions.
//
// }
type RunnerUpdaterMock struct {
// DoUpdateFunc mocks the DoUpdate method.
DoUpdateFunc func(url string) error
// GetLastRefreshFunc mocks the GetLastRefresh method.
GetLastRefreshFunc func(file string) time.Duration
// GetUpdateVersionFunc mocks the GetUpdateVersion method.
GetUpdateVersionFunc func() (string, error)
// RestartFunc mocks the Restart method.
RestartFunc func() int
// RunFunc mocks the Run method.
RunFunc func() int
// SetLastRefreshFunc mocks the SetLastRefresh method.
SetLastRefreshFunc func(file string)
// ShouldUpdateFunc mocks the ShouldUpdate method.
ShouldUpdateFunc func() bool
// calls tracks calls to the methods.
calls struct {
// DoUpdate holds details about calls to the DoUpdate method.
DoUpdate []struct {
// URL is the url argument value.
URL string
}
// GetLastRefresh holds details about calls to the GetLastRefresh method.
GetLastRefresh []struct {
// File is the file argument value.
File string
}
// GetUpdateVersion holds details about calls to the GetUpdateVersion method.
GetUpdateVersion []struct {
}
// Restart holds details about calls to the Restart method.
Restart []struct {
}
// Run holds details about calls to the Run method.
Run []struct {
}
// SetLastRefresh holds details about calls to the SetLastRefresh method.
SetLastRefresh []struct {
// File is the file argument value.
File string
}
// ShouldUpdate holds details about calls to the ShouldUpdate method.
ShouldUpdate []struct {
}
}
lockDoUpdate sync.RWMutex
lockGetLastRefresh sync.RWMutex
lockGetUpdateVersion sync.RWMutex
lockRestart sync.RWMutex
lockRun sync.RWMutex
lockSetLastRefresh sync.RWMutex
lockShouldUpdate sync.RWMutex
}
// DoUpdate calls DoUpdateFunc.
func (mock *RunnerUpdaterMock) DoUpdate(url string) error {
if mock.DoUpdateFunc == nil {
panic("RunnerUpdaterMock.DoUpdateFunc: method is nil but RunnerUpdater.DoUpdate was just called")
}
callInfo := struct {
URL string
}{
URL: url,
}
mock.lockDoUpdate.Lock()
mock.calls.DoUpdate = append(mock.calls.DoUpdate, callInfo)
mock.lockDoUpdate.Unlock()
return mock.DoUpdateFunc(url)
}
// DoUpdateCalls gets all the calls that were made to DoUpdate.
// Check the length with:
//
// len(mockedRunnerUpdater.DoUpdateCalls())
func (mock *RunnerUpdaterMock) DoUpdateCalls() []struct {
URL string
} {
var calls []struct {
URL string
}
mock.lockDoUpdate.RLock()
calls = mock.calls.DoUpdate
mock.lockDoUpdate.RUnlock()
return calls
}
// GetLastRefresh calls GetLastRefreshFunc.
func (mock *RunnerUpdaterMock) GetLastRefresh(file string) time.Duration {
if mock.GetLastRefreshFunc == nil {
panic("RunnerUpdaterMock.GetLastRefreshFunc: method is nil but RunnerUpdater.GetLastRefresh was just called")
}
callInfo := struct {
File string
}{
File: file,
}
mock.lockGetLastRefresh.Lock()
mock.calls.GetLastRefresh = append(mock.calls.GetLastRefresh, callInfo)
mock.lockGetLastRefresh.Unlock()
return mock.GetLastRefreshFunc(file)
}
// GetLastRefreshCalls gets all the calls that were made to GetLastRefresh.
// Check the length with:
//
// len(mockedRunnerUpdater.GetLastRefreshCalls())
func (mock *RunnerUpdaterMock) GetLastRefreshCalls() []struct {
File string
} {
var calls []struct {
File string
}
mock.lockGetLastRefresh.RLock()
calls = mock.calls.GetLastRefresh
mock.lockGetLastRefresh.RUnlock()
return calls
}
// GetUpdateVersion calls GetUpdateVersionFunc.
func (mock *RunnerUpdaterMock) GetUpdateVersion() (string, error) {
if mock.GetUpdateVersionFunc == nil {
panic("RunnerUpdaterMock.GetUpdateVersionFunc: method is nil but RunnerUpdater.GetUpdateVersion was just called")
}
callInfo := struct {
}{}
mock.lockGetUpdateVersion.Lock()
mock.calls.GetUpdateVersion = append(mock.calls.GetUpdateVersion, callInfo)
mock.lockGetUpdateVersion.Unlock()
return mock.GetUpdateVersionFunc()
}
// GetUpdateVersionCalls gets all the calls that were made to GetUpdateVersion.
// Check the length with:
//
// len(mockedRunnerUpdater.GetUpdateVersionCalls())
func (mock *RunnerUpdaterMock) GetUpdateVersionCalls() []struct {
} {
var calls []struct {
}
mock.lockGetUpdateVersion.RLock()
calls = mock.calls.GetUpdateVersion
mock.lockGetUpdateVersion.RUnlock()
return calls
}
// Restart calls RestartFunc.
func (mock *RunnerUpdaterMock) Restart() int {
if mock.RestartFunc == nil {
panic("RunnerUpdaterMock.RestartFunc: method is nil but RunnerUpdater.Restart was just called")
}
callInfo := struct {
}{}
mock.lockRestart.Lock()
mock.calls.Restart = append(mock.calls.Restart, callInfo)
mock.lockRestart.Unlock()
return mock.RestartFunc()
}
// RestartCalls gets all the calls that were made to Restart.
// Check the length with:
//
// len(mockedRunnerUpdater.RestartCalls())
func (mock *RunnerUpdaterMock) RestartCalls() []struct {
} {
var calls []struct {
}
mock.lockRestart.RLock()
calls = mock.calls.Restart
mock.lockRestart.RUnlock()
return calls
}
// Run calls RunFunc.
func (mock *RunnerUpdaterMock) Run() int {
if mock.RunFunc == nil {
panic("RunnerUpdaterMock.RunFunc: method is nil but RunnerUpdater.Run was just called")
}
callInfo := struct {
}{}
mock.lockRun.Lock()
mock.calls.Run = append(mock.calls.Run, callInfo)
mock.lockRun.Unlock()
return mock.RunFunc()
}
// RunCalls gets all the calls that were made to Run.
// Check the length with:
//
// len(mockedRunnerUpdater.RunCalls())
func (mock *RunnerUpdaterMock) RunCalls() []struct {
} {
var calls []struct {
}
mock.lockRun.RLock()
calls = mock.calls.Run
mock.lockRun.RUnlock()
return calls
}
// SetLastRefresh calls SetLastRefreshFunc.
func (mock *RunnerUpdaterMock) SetLastRefresh(file string) {
if mock.SetLastRefreshFunc == nil {
panic("RunnerUpdaterMock.SetLastRefreshFunc: method is nil but RunnerUpdater.SetLastRefresh was just called")
}
callInfo := struct {
File string
}{
File: file,
}
mock.lockSetLastRefresh.Lock()
mock.calls.SetLastRefresh = append(mock.calls.SetLastRefresh, callInfo)
mock.lockSetLastRefresh.Unlock()
mock.SetLastRefreshFunc(file)
}
// SetLastRefreshCalls gets all the calls that were made to SetLastRefresh.
// Check the length with:
//
// len(mockedRunnerUpdater.SetLastRefreshCalls())
func (mock *RunnerUpdaterMock) SetLastRefreshCalls() []struct {
File string
} {
var calls []struct {
File string
}
mock.lockSetLastRefresh.RLock()
calls = mock.calls.SetLastRefresh
mock.lockSetLastRefresh.RUnlock()
return calls
}
// ShouldUpdate calls ShouldUpdateFunc.
func (mock *RunnerUpdaterMock) ShouldUpdate() bool {
if mock.ShouldUpdateFunc == nil {
panic("RunnerUpdaterMock.ShouldUpdateFunc: method is nil but RunnerUpdater.ShouldUpdate was just called")
}
callInfo := struct {
}{}
mock.lockShouldUpdate.Lock()
mock.calls.ShouldUpdate = append(mock.calls.ShouldUpdate, callInfo)
mock.lockShouldUpdate.Unlock()
return mock.ShouldUpdateFunc()
}
// ShouldUpdateCalls gets all the calls that were made to ShouldUpdate.
// Check the length with:
//
// len(mockedRunnerUpdater.ShouldUpdateCalls())
func (mock *RunnerUpdaterMock) ShouldUpdateCalls() []struct {
} {
var calls []struct {
}
mock.lockShouldUpdate.RLock()
calls = mock.calls.ShouldUpdate
mock.lockShouldUpdate.RUnlock()
return calls
}