/
mock_gen.go
281 lines (259 loc) · 7.66 KB
/
mock_gen.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
// Code generated by moq; DO NOT EDIT.
// github.com/matryer/moq
package main
import (
"github.com/ktr0731/evans/prompt"
"sync"
)
// Ensure, that PromptMock does implement prompt.Prompt.
// If this is not the case, regenerate this file with moq.
var _ prompt.Prompt = &PromptMock{}
// PromptMock is a mock implementation of prompt.Prompt.
//
// func TestSomethingThatUsesPrompt(t *testing.T) {
//
// // make and configure a mocked prompt.Prompt
// mockedPrompt := &PromptMock{
// GetCommandHistoryFunc: func() []string {
// panic("mock out the GetCommandHistory method")
// },
// InputFunc: func() (string, error) {
// panic("mock out the Input method")
// },
// SelectFunc: func(message string, options []string) (int, string, error) {
// panic("mock out the Select method")
// },
// SetCompleterFunc: func(c prompt.Completer) {
// panic("mock out the SetCompleter method")
// },
// SetPrefixFunc: func(prefix string) {
// panic("mock out the SetPrefix method")
// },
// SetPrefixColorFunc: func(color prompt.Color) {
// panic("mock out the SetPrefixColor method")
// },
// }
//
// // use mockedPrompt in code that requires prompt.Prompt
// // and then make assertions.
//
// }
type PromptMock struct {
// GetCommandHistoryFunc mocks the GetCommandHistory method.
GetCommandHistoryFunc func() []string
// InputFunc mocks the Input method.
InputFunc func() (string, error)
// SelectFunc mocks the Select method.
SelectFunc func(message string, options []string) (int, string, error)
// SetCompleterFunc mocks the SetCompleter method.
SetCompleterFunc func(c prompt.Completer)
// SetPrefixFunc mocks the SetPrefix method.
SetPrefixFunc func(prefix string)
// SetPrefixColorFunc mocks the SetPrefixColor method.
SetPrefixColorFunc func(color prompt.Color)
// calls tracks calls to the methods.
calls struct {
// GetCommandHistory holds details about calls to the GetCommandHistory method.
GetCommandHistory []struct {
}
// Input holds details about calls to the Input method.
Input []struct {
}
// Select holds details about calls to the Select method.
Select []struct {
// Message is the message argument value.
Message string
// Options is the options argument value.
Options []string
}
// SetCompleter holds details about calls to the SetCompleter method.
SetCompleter []struct {
// C is the c argument value.
C prompt.Completer
}
// SetPrefix holds details about calls to the SetPrefix method.
SetPrefix []struct {
// Prefix is the prefix argument value.
Prefix string
}
// SetPrefixColor holds details about calls to the SetPrefixColor method.
SetPrefixColor []struct {
// Color is the color argument value.
Color prompt.Color
}
}
lockGetCommandHistory sync.RWMutex
lockInput sync.RWMutex
lockSelect sync.RWMutex
lockSetCompleter sync.RWMutex
lockSetPrefix sync.RWMutex
lockSetPrefixColor sync.RWMutex
}
// GetCommandHistory calls GetCommandHistoryFunc.
func (mock *PromptMock) GetCommandHistory() []string {
if mock.GetCommandHistoryFunc == nil {
panic("PromptMock.GetCommandHistoryFunc: method is nil but Prompt.GetCommandHistory was just called")
}
callInfo := struct {
}{}
mock.lockGetCommandHistory.Lock()
mock.calls.GetCommandHistory = append(mock.calls.GetCommandHistory, callInfo)
mock.lockGetCommandHistory.Unlock()
return mock.GetCommandHistoryFunc()
}
// GetCommandHistoryCalls gets all the calls that were made to GetCommandHistory.
// Check the length with:
// len(mockedPrompt.GetCommandHistoryCalls())
func (mock *PromptMock) GetCommandHistoryCalls() []struct {
} {
var calls []struct {
}
mock.lockGetCommandHistory.RLock()
calls = mock.calls.GetCommandHistory
mock.lockGetCommandHistory.RUnlock()
return calls
}
// Input calls InputFunc.
func (mock *PromptMock) Input() (string, error) {
if mock.InputFunc == nil {
panic("PromptMock.InputFunc: method is nil but Prompt.Input was just called")
}
callInfo := struct {
}{}
mock.lockInput.Lock()
mock.calls.Input = append(mock.calls.Input, callInfo)
mock.lockInput.Unlock()
return mock.InputFunc()
}
// InputCalls gets all the calls that were made to Input.
// Check the length with:
// len(mockedPrompt.InputCalls())
func (mock *PromptMock) InputCalls() []struct {
} {
var calls []struct {
}
mock.lockInput.RLock()
calls = mock.calls.Input
mock.lockInput.RUnlock()
return calls
}
// Select calls SelectFunc.
func (mock *PromptMock) Select(message string, options []string) (int, string, error) {
if mock.SelectFunc == nil {
panic("PromptMock.SelectFunc: method is nil but Prompt.Select was just called")
}
callInfo := struct {
Message string
Options []string
}{
Message: message,
Options: options,
}
mock.lockSelect.Lock()
mock.calls.Select = append(mock.calls.Select, callInfo)
mock.lockSelect.Unlock()
return mock.SelectFunc(message, options)
}
// SelectCalls gets all the calls that were made to Select.
// Check the length with:
// len(mockedPrompt.SelectCalls())
func (mock *PromptMock) SelectCalls() []struct {
Message string
Options []string
} {
var calls []struct {
Message string
Options []string
}
mock.lockSelect.RLock()
calls = mock.calls.Select
mock.lockSelect.RUnlock()
return calls
}
// SetCompleter calls SetCompleterFunc.
func (mock *PromptMock) SetCompleter(c prompt.Completer) {
if mock.SetCompleterFunc == nil {
panic("PromptMock.SetCompleterFunc: method is nil but Prompt.SetCompleter was just called")
}
callInfo := struct {
C prompt.Completer
}{
C: c,
}
mock.lockSetCompleter.Lock()
mock.calls.SetCompleter = append(mock.calls.SetCompleter, callInfo)
mock.lockSetCompleter.Unlock()
mock.SetCompleterFunc(c)
}
// SetCompleterCalls gets all the calls that were made to SetCompleter.
// Check the length with:
// len(mockedPrompt.SetCompleterCalls())
func (mock *PromptMock) SetCompleterCalls() []struct {
C prompt.Completer
} {
var calls []struct {
C prompt.Completer
}
mock.lockSetCompleter.RLock()
calls = mock.calls.SetCompleter
mock.lockSetCompleter.RUnlock()
return calls
}
// SetPrefix calls SetPrefixFunc.
func (mock *PromptMock) SetPrefix(prefix string) {
if mock.SetPrefixFunc == nil {
panic("PromptMock.SetPrefixFunc: method is nil but Prompt.SetPrefix was just called")
}
callInfo := struct {
Prefix string
}{
Prefix: prefix,
}
mock.lockSetPrefix.Lock()
mock.calls.SetPrefix = append(mock.calls.SetPrefix, callInfo)
mock.lockSetPrefix.Unlock()
mock.SetPrefixFunc(prefix)
}
// SetPrefixCalls gets all the calls that were made to SetPrefix.
// Check the length with:
// len(mockedPrompt.SetPrefixCalls())
func (mock *PromptMock) SetPrefixCalls() []struct {
Prefix string
} {
var calls []struct {
Prefix string
}
mock.lockSetPrefix.RLock()
calls = mock.calls.SetPrefix
mock.lockSetPrefix.RUnlock()
return calls
}
// SetPrefixColor calls SetPrefixColorFunc.
func (mock *PromptMock) SetPrefixColor(color prompt.Color) {
if mock.SetPrefixColorFunc == nil {
panic("PromptMock.SetPrefixColorFunc: method is nil but Prompt.SetPrefixColor was just called")
}
callInfo := struct {
Color prompt.Color
}{
Color: color,
}
mock.lockSetPrefixColor.Lock()
mock.calls.SetPrefixColor = append(mock.calls.SetPrefixColor, callInfo)
mock.lockSetPrefixColor.Unlock()
mock.SetPrefixColorFunc(color)
}
// SetPrefixColorCalls gets all the calls that were made to SetPrefixColor.
// Check the length with:
// len(mockedPrompt.SetPrefixColorCalls())
func (mock *PromptMock) SetPrefixColorCalls() []struct {
Color prompt.Color
} {
var calls []struct {
Color prompt.Color
}
mock.lockSetPrefixColor.RLock()
calls = mock.calls.SetPrefixColor
mock.lockSetPrefixColor.RUnlock()
return calls
}