-
Notifications
You must be signed in to change notification settings - Fork 0
/
fake_printer.go
217 lines (194 loc) · 5.79 KB
/
fake_printer.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
// Code generated by counterfeiter. DO NOT EDIT.
package tracefakes
import (
"sync"
"code.cloudfoundry.org/cli/cf/trace"
)
type FakePrinter struct {
PrintStub func(...interface{})
printMutex sync.RWMutex
printArgsForCall []struct {
arg1 []interface{}
}
PrintfStub func(string, ...interface{})
printfMutex sync.RWMutex
printfArgsForCall []struct {
arg1 string
arg2 []interface{}
}
PrintlnStub func(...interface{})
printlnMutex sync.RWMutex
printlnArgsForCall []struct {
arg1 []interface{}
}
WritesToConsoleStub func() bool
writesToConsoleMutex sync.RWMutex
writesToConsoleArgsForCall []struct {
}
writesToConsoleReturns struct {
result1 bool
}
writesToConsoleReturnsOnCall map[int]struct {
result1 bool
}
invocations map[string][][]interface{}
invocationsMutex sync.RWMutex
}
func (fake *FakePrinter) Print(arg1 ...interface{}) {
fake.printMutex.Lock()
fake.printArgsForCall = append(fake.printArgsForCall, struct {
arg1 []interface{}
}{arg1})
fake.recordInvocation("Print", []interface{}{arg1})
fake.printMutex.Unlock()
if fake.PrintStub != nil {
fake.PrintStub(arg1...)
}
}
func (fake *FakePrinter) PrintCallCount() int {
fake.printMutex.RLock()
defer fake.printMutex.RUnlock()
return len(fake.printArgsForCall)
}
func (fake *FakePrinter) PrintCalls(stub func(...interface{})) {
fake.printMutex.Lock()
defer fake.printMutex.Unlock()
fake.PrintStub = stub
}
func (fake *FakePrinter) PrintArgsForCall(i int) []interface{} {
fake.printMutex.RLock()
defer fake.printMutex.RUnlock()
argsForCall := fake.printArgsForCall[i]
return argsForCall.arg1
}
func (fake *FakePrinter) Printf(arg1 string, arg2 ...interface{}) {
fake.printfMutex.Lock()
fake.printfArgsForCall = append(fake.printfArgsForCall, struct {
arg1 string
arg2 []interface{}
}{arg1, arg2})
fake.recordInvocation("Printf", []interface{}{arg1, arg2})
fake.printfMutex.Unlock()
if fake.PrintfStub != nil {
fake.PrintfStub(arg1, arg2...)
}
}
func (fake *FakePrinter) PrintfCallCount() int {
fake.printfMutex.RLock()
defer fake.printfMutex.RUnlock()
return len(fake.printfArgsForCall)
}
func (fake *FakePrinter) PrintfCalls(stub func(string, ...interface{})) {
fake.printfMutex.Lock()
defer fake.printfMutex.Unlock()
fake.PrintfStub = stub
}
func (fake *FakePrinter) PrintfArgsForCall(i int) (string, []interface{}) {
fake.printfMutex.RLock()
defer fake.printfMutex.RUnlock()
argsForCall := fake.printfArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2
}
func (fake *FakePrinter) Println(arg1 ...interface{}) {
fake.printlnMutex.Lock()
fake.printlnArgsForCall = append(fake.printlnArgsForCall, struct {
arg1 []interface{}
}{arg1})
fake.recordInvocation("Println", []interface{}{arg1})
fake.printlnMutex.Unlock()
if fake.PrintlnStub != nil {
fake.PrintlnStub(arg1...)
}
}
func (fake *FakePrinter) PrintlnCallCount() int {
fake.printlnMutex.RLock()
defer fake.printlnMutex.RUnlock()
return len(fake.printlnArgsForCall)
}
func (fake *FakePrinter) PrintlnCalls(stub func(...interface{})) {
fake.printlnMutex.Lock()
defer fake.printlnMutex.Unlock()
fake.PrintlnStub = stub
}
func (fake *FakePrinter) PrintlnArgsForCall(i int) []interface{} {
fake.printlnMutex.RLock()
defer fake.printlnMutex.RUnlock()
argsForCall := fake.printlnArgsForCall[i]
return argsForCall.arg1
}
func (fake *FakePrinter) WritesToConsole() bool {
fake.writesToConsoleMutex.Lock()
ret, specificReturn := fake.writesToConsoleReturnsOnCall[len(fake.writesToConsoleArgsForCall)]
fake.writesToConsoleArgsForCall = append(fake.writesToConsoleArgsForCall, struct {
}{})
fake.recordInvocation("WritesToConsole", []interface{}{})
fake.writesToConsoleMutex.Unlock()
if fake.WritesToConsoleStub != nil {
return fake.WritesToConsoleStub()
}
if specificReturn {
return ret.result1
}
fakeReturns := fake.writesToConsoleReturns
return fakeReturns.result1
}
func (fake *FakePrinter) WritesToConsoleCallCount() int {
fake.writesToConsoleMutex.RLock()
defer fake.writesToConsoleMutex.RUnlock()
return len(fake.writesToConsoleArgsForCall)
}
func (fake *FakePrinter) WritesToConsoleCalls(stub func() bool) {
fake.writesToConsoleMutex.Lock()
defer fake.writesToConsoleMutex.Unlock()
fake.WritesToConsoleStub = stub
}
func (fake *FakePrinter) WritesToConsoleReturns(result1 bool) {
fake.writesToConsoleMutex.Lock()
defer fake.writesToConsoleMutex.Unlock()
fake.WritesToConsoleStub = nil
fake.writesToConsoleReturns = struct {
result1 bool
}{result1}
}
func (fake *FakePrinter) WritesToConsoleReturnsOnCall(i int, result1 bool) {
fake.writesToConsoleMutex.Lock()
defer fake.writesToConsoleMutex.Unlock()
fake.WritesToConsoleStub = nil
if fake.writesToConsoleReturnsOnCall == nil {
fake.writesToConsoleReturnsOnCall = make(map[int]struct {
result1 bool
})
}
fake.writesToConsoleReturnsOnCall[i] = struct {
result1 bool
}{result1}
}
func (fake *FakePrinter) Invocations() map[string][][]interface{} {
fake.invocationsMutex.RLock()
defer fake.invocationsMutex.RUnlock()
fake.printMutex.RLock()
defer fake.printMutex.RUnlock()
fake.printfMutex.RLock()
defer fake.printfMutex.RUnlock()
fake.printlnMutex.RLock()
defer fake.printlnMutex.RUnlock()
fake.writesToConsoleMutex.RLock()
defer fake.writesToConsoleMutex.RUnlock()
copiedInvocations := map[string][][]interface{}{}
for key, value := range fake.invocations {
copiedInvocations[key] = value
}
return copiedInvocations
}
func (fake *FakePrinter) recordInvocation(key string, args []interface{}) {
fake.invocationsMutex.Lock()
defer fake.invocationsMutex.Unlock()
if fake.invocations == nil {
fake.invocations = map[string][][]interface{}{}
}
if fake.invocations[key] == nil {
fake.invocations[key] = [][]interface{}{}
}
fake.invocations[key] = append(fake.invocations[key], args)
}
var _ trace.Printer = new(FakePrinter)