-
Notifications
You must be signed in to change notification settings - Fork 5.4k
/
prompter_mock.go
460 lines (429 loc) · 11.9 KB
/
prompter_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
// Code generated by moq; DO NOT EDIT.
// github.com/matryer/moq
package prompter
import (
"sync"
)
// Ensure, that PrompterMock does implement Prompter.
// If this is not the case, regenerate this file with moq.
var _ Prompter = &PrompterMock{}
// PrompterMock is a mock implementation of Prompter.
//
// func TestSomethingThatUsesPrompter(t *testing.T) {
//
// // make and configure a mocked Prompter
// mockedPrompter := &PrompterMock{
// AuthTokenFunc: func() (string, error) {
// panic("mock out the AuthToken method")
// },
// ConfirmFunc: func(s string, b bool) (bool, error) {
// panic("mock out the Confirm method")
// },
// ConfirmDeletionFunc: func(s string) error {
// panic("mock out the ConfirmDeletion method")
// },
// InputFunc: func(s1 string, s2 string) (string, error) {
// panic("mock out the Input method")
// },
// InputHostnameFunc: func() (string, error) {
// panic("mock out the InputHostname method")
// },
// MarkdownEditorFunc: func(s1 string, s2 string, b bool) (string, error) {
// panic("mock out the MarkdownEditor method")
// },
// MultiSelectFunc: func(prompt string, defaults []string, options []string) ([]int, error) {
// panic("mock out the MultiSelect method")
// },
// PasswordFunc: func(s string) (string, error) {
// panic("mock out the Password method")
// },
// SelectFunc: func(s1 string, s2 string, strings []string) (int, error) {
// panic("mock out the Select method")
// },
// }
//
// // use mockedPrompter in code that requires Prompter
// // and then make assertions.
//
// }
type PrompterMock struct {
// AuthTokenFunc mocks the AuthToken method.
AuthTokenFunc func() (string, error)
// ConfirmFunc mocks the Confirm method.
ConfirmFunc func(s string, b bool) (bool, error)
// ConfirmDeletionFunc mocks the ConfirmDeletion method.
ConfirmDeletionFunc func(s string) error
// InputFunc mocks the Input method.
InputFunc func(s1 string, s2 string) (string, error)
// InputHostnameFunc mocks the InputHostname method.
InputHostnameFunc func() (string, error)
// MarkdownEditorFunc mocks the MarkdownEditor method.
MarkdownEditorFunc func(s1 string, s2 string, b bool) (string, error)
// MultiSelectFunc mocks the MultiSelect method.
MultiSelectFunc func(prompt string, defaults []string, options []string) ([]int, error)
// PasswordFunc mocks the Password method.
PasswordFunc func(s string) (string, error)
// SelectFunc mocks the Select method.
SelectFunc func(s1 string, s2 string, strings []string) (int, error)
// calls tracks calls to the methods.
calls struct {
// AuthToken holds details about calls to the AuthToken method.
AuthToken []struct {
}
// Confirm holds details about calls to the Confirm method.
Confirm []struct {
// S is the s argument value.
S string
// B is the b argument value.
B bool
}
// ConfirmDeletion holds details about calls to the ConfirmDeletion method.
ConfirmDeletion []struct {
// S is the s argument value.
S string
}
// Input holds details about calls to the Input method.
Input []struct {
// S1 is the s1 argument value.
S1 string
// S2 is the s2 argument value.
S2 string
}
// InputHostname holds details about calls to the InputHostname method.
InputHostname []struct {
}
// MarkdownEditor holds details about calls to the MarkdownEditor method.
MarkdownEditor []struct {
// S1 is the s1 argument value.
S1 string
// S2 is the s2 argument value.
S2 string
// B is the b argument value.
B bool
}
// MultiSelect holds details about calls to the MultiSelect method.
MultiSelect []struct {
// Prompt is the prompt argument value.
Prompt string
// Defaults is the defaults argument value.
Defaults []string
// Options is the options argument value.
Options []string
}
// Password holds details about calls to the Password method.
Password []struct {
// S is the s argument value.
S string
}
// Select holds details about calls to the Select method.
Select []struct {
// S1 is the s1 argument value.
S1 string
// S2 is the s2 argument value.
S2 string
// Strings is the strings argument value.
Strings []string
}
}
lockAuthToken sync.RWMutex
lockConfirm sync.RWMutex
lockConfirmDeletion sync.RWMutex
lockInput sync.RWMutex
lockInputHostname sync.RWMutex
lockMarkdownEditor sync.RWMutex
lockMultiSelect sync.RWMutex
lockPassword sync.RWMutex
lockSelect sync.RWMutex
}
// AuthToken calls AuthTokenFunc.
func (mock *PrompterMock) AuthToken() (string, error) {
if mock.AuthTokenFunc == nil {
panic("PrompterMock.AuthTokenFunc: method is nil but Prompter.AuthToken was just called")
}
callInfo := struct {
}{}
mock.lockAuthToken.Lock()
mock.calls.AuthToken = append(mock.calls.AuthToken, callInfo)
mock.lockAuthToken.Unlock()
return mock.AuthTokenFunc()
}
// AuthTokenCalls gets all the calls that were made to AuthToken.
// Check the length with:
//
// len(mockedPrompter.AuthTokenCalls())
func (mock *PrompterMock) AuthTokenCalls() []struct {
} {
var calls []struct {
}
mock.lockAuthToken.RLock()
calls = mock.calls.AuthToken
mock.lockAuthToken.RUnlock()
return calls
}
// Confirm calls ConfirmFunc.
func (mock *PrompterMock) Confirm(s string, b bool) (bool, error) {
if mock.ConfirmFunc == nil {
panic("PrompterMock.ConfirmFunc: method is nil but Prompter.Confirm was just called")
}
callInfo := struct {
S string
B bool
}{
S: s,
B: b,
}
mock.lockConfirm.Lock()
mock.calls.Confirm = append(mock.calls.Confirm, callInfo)
mock.lockConfirm.Unlock()
return mock.ConfirmFunc(s, b)
}
// ConfirmCalls gets all the calls that were made to Confirm.
// Check the length with:
//
// len(mockedPrompter.ConfirmCalls())
func (mock *PrompterMock) ConfirmCalls() []struct {
S string
B bool
} {
var calls []struct {
S string
B bool
}
mock.lockConfirm.RLock()
calls = mock.calls.Confirm
mock.lockConfirm.RUnlock()
return calls
}
// ConfirmDeletion calls ConfirmDeletionFunc.
func (mock *PrompterMock) ConfirmDeletion(s string) error {
if mock.ConfirmDeletionFunc == nil {
panic("PrompterMock.ConfirmDeletionFunc: method is nil but Prompter.ConfirmDeletion was just called")
}
callInfo := struct {
S string
}{
S: s,
}
mock.lockConfirmDeletion.Lock()
mock.calls.ConfirmDeletion = append(mock.calls.ConfirmDeletion, callInfo)
mock.lockConfirmDeletion.Unlock()
return mock.ConfirmDeletionFunc(s)
}
// ConfirmDeletionCalls gets all the calls that were made to ConfirmDeletion.
// Check the length with:
//
// len(mockedPrompter.ConfirmDeletionCalls())
func (mock *PrompterMock) ConfirmDeletionCalls() []struct {
S string
} {
var calls []struct {
S string
}
mock.lockConfirmDeletion.RLock()
calls = mock.calls.ConfirmDeletion
mock.lockConfirmDeletion.RUnlock()
return calls
}
// Input calls InputFunc.
func (mock *PrompterMock) Input(s1 string, s2 string) (string, error) {
if mock.InputFunc == nil {
panic("PrompterMock.InputFunc: method is nil but Prompter.Input was just called")
}
callInfo := struct {
S1 string
S2 string
}{
S1: s1,
S2: s2,
}
mock.lockInput.Lock()
mock.calls.Input = append(mock.calls.Input, callInfo)
mock.lockInput.Unlock()
return mock.InputFunc(s1, s2)
}
// InputCalls gets all the calls that were made to Input.
// Check the length with:
//
// len(mockedPrompter.InputCalls())
func (mock *PrompterMock) InputCalls() []struct {
S1 string
S2 string
} {
var calls []struct {
S1 string
S2 string
}
mock.lockInput.RLock()
calls = mock.calls.Input
mock.lockInput.RUnlock()
return calls
}
// InputHostname calls InputHostnameFunc.
func (mock *PrompterMock) InputHostname() (string, error) {
if mock.InputHostnameFunc == nil {
panic("PrompterMock.InputHostnameFunc: method is nil but Prompter.InputHostname was just called")
}
callInfo := struct {
}{}
mock.lockInputHostname.Lock()
mock.calls.InputHostname = append(mock.calls.InputHostname, callInfo)
mock.lockInputHostname.Unlock()
return mock.InputHostnameFunc()
}
// InputHostnameCalls gets all the calls that were made to InputHostname.
// Check the length with:
//
// len(mockedPrompter.InputHostnameCalls())
func (mock *PrompterMock) InputHostnameCalls() []struct {
} {
var calls []struct {
}
mock.lockInputHostname.RLock()
calls = mock.calls.InputHostname
mock.lockInputHostname.RUnlock()
return calls
}
// MarkdownEditor calls MarkdownEditorFunc.
func (mock *PrompterMock) MarkdownEditor(s1 string, s2 string, b bool) (string, error) {
if mock.MarkdownEditorFunc == nil {
panic("PrompterMock.MarkdownEditorFunc: method is nil but Prompter.MarkdownEditor was just called")
}
callInfo := struct {
S1 string
S2 string
B bool
}{
S1: s1,
S2: s2,
B: b,
}
mock.lockMarkdownEditor.Lock()
mock.calls.MarkdownEditor = append(mock.calls.MarkdownEditor, callInfo)
mock.lockMarkdownEditor.Unlock()
return mock.MarkdownEditorFunc(s1, s2, b)
}
// MarkdownEditorCalls gets all the calls that were made to MarkdownEditor.
// Check the length with:
//
// len(mockedPrompter.MarkdownEditorCalls())
func (mock *PrompterMock) MarkdownEditorCalls() []struct {
S1 string
S2 string
B bool
} {
var calls []struct {
S1 string
S2 string
B bool
}
mock.lockMarkdownEditor.RLock()
calls = mock.calls.MarkdownEditor
mock.lockMarkdownEditor.RUnlock()
return calls
}
// MultiSelect calls MultiSelectFunc.
func (mock *PrompterMock) MultiSelect(prompt string, defaults []string, options []string) ([]int, error) {
if mock.MultiSelectFunc == nil {
panic("PrompterMock.MultiSelectFunc: method is nil but Prompter.MultiSelect was just called")
}
callInfo := struct {
Prompt string
Defaults []string
Options []string
}{
Prompt: prompt,
Defaults: defaults,
Options: options,
}
mock.lockMultiSelect.Lock()
mock.calls.MultiSelect = append(mock.calls.MultiSelect, callInfo)
mock.lockMultiSelect.Unlock()
return mock.MultiSelectFunc(prompt, defaults, options)
}
// MultiSelectCalls gets all the calls that were made to MultiSelect.
// Check the length with:
//
// len(mockedPrompter.MultiSelectCalls())
func (mock *PrompterMock) MultiSelectCalls() []struct {
Prompt string
Defaults []string
Options []string
} {
var calls []struct {
Prompt string
Defaults []string
Options []string
}
mock.lockMultiSelect.RLock()
calls = mock.calls.MultiSelect
mock.lockMultiSelect.RUnlock()
return calls
}
// Password calls PasswordFunc.
func (mock *PrompterMock) Password(s string) (string, error) {
if mock.PasswordFunc == nil {
panic("PrompterMock.PasswordFunc: method is nil but Prompter.Password was just called")
}
callInfo := struct {
S string
}{
S: s,
}
mock.lockPassword.Lock()
mock.calls.Password = append(mock.calls.Password, callInfo)
mock.lockPassword.Unlock()
return mock.PasswordFunc(s)
}
// PasswordCalls gets all the calls that were made to Password.
// Check the length with:
//
// len(mockedPrompter.PasswordCalls())
func (mock *PrompterMock) PasswordCalls() []struct {
S string
} {
var calls []struct {
S string
}
mock.lockPassword.RLock()
calls = mock.calls.Password
mock.lockPassword.RUnlock()
return calls
}
// Select calls SelectFunc.
func (mock *PrompterMock) Select(s1 string, s2 string, strings []string) (int, error) {
if mock.SelectFunc == nil {
panic("PrompterMock.SelectFunc: method is nil but Prompter.Select was just called")
}
callInfo := struct {
S1 string
S2 string
Strings []string
}{
S1: s1,
S2: s2,
Strings: strings,
}
mock.lockSelect.Lock()
mock.calls.Select = append(mock.calls.Select, callInfo)
mock.lockSelect.Unlock()
return mock.SelectFunc(s1, s2, strings)
}
// SelectCalls gets all the calls that were made to Select.
// Check the length with:
//
// len(mockedPrompter.SelectCalls())
func (mock *PrompterMock) SelectCalls() []struct {
S1 string
S2 string
Strings []string
} {
var calls []struct {
S1 string
S2 string
Strings []string
}
mock.lockSelect.RLock()
calls = mock.calls.Select
mock.lockSelect.RUnlock()
return calls
}