-
Notifications
You must be signed in to change notification settings - Fork 0
/
portAllocator.go
158 lines (144 loc) · 4.43 KB
/
portAllocator.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
// This file was generated by counterfeiter
package fakes
import (
"sync"
)
type PortAllocator struct {
AllocatePortStub func(handle string, port int) (int, error)
allocatePortMutex sync.RWMutex
allocatePortArgsForCall []struct {
handle string
port int
}
allocatePortReturns struct {
result1 int
result2 error
}
allocatePortReturnsOnCall map[int]struct {
result1 int
result2 error
}
ReleaseAllPortsStub func(handle string) error
releaseAllPortsMutex sync.RWMutex
releaseAllPortsArgsForCall []struct {
handle string
}
releaseAllPortsReturns struct {
result1 error
}
releaseAllPortsReturnsOnCall map[int]struct {
result1 error
}
invocations map[string][][]interface{}
invocationsMutex sync.RWMutex
}
func (fake *PortAllocator) AllocatePort(handle string, port int) (int, error) {
fake.allocatePortMutex.Lock()
ret, specificReturn := fake.allocatePortReturnsOnCall[len(fake.allocatePortArgsForCall)]
fake.allocatePortArgsForCall = append(fake.allocatePortArgsForCall, struct {
handle string
port int
}{handle, port})
fake.recordInvocation("AllocatePort", []interface{}{handle, port})
fake.allocatePortMutex.Unlock()
if fake.AllocatePortStub != nil {
return fake.AllocatePortStub(handle, port)
}
if specificReturn {
return ret.result1, ret.result2
}
return fake.allocatePortReturns.result1, fake.allocatePortReturns.result2
}
func (fake *PortAllocator) AllocatePortCallCount() int {
fake.allocatePortMutex.RLock()
defer fake.allocatePortMutex.RUnlock()
return len(fake.allocatePortArgsForCall)
}
func (fake *PortAllocator) AllocatePortArgsForCall(i int) (string, int) {
fake.allocatePortMutex.RLock()
defer fake.allocatePortMutex.RUnlock()
return fake.allocatePortArgsForCall[i].handle, fake.allocatePortArgsForCall[i].port
}
func (fake *PortAllocator) AllocatePortReturns(result1 int, result2 error) {
fake.AllocatePortStub = nil
fake.allocatePortReturns = struct {
result1 int
result2 error
}{result1, result2}
}
func (fake *PortAllocator) AllocatePortReturnsOnCall(i int, result1 int, result2 error) {
fake.AllocatePortStub = nil
if fake.allocatePortReturnsOnCall == nil {
fake.allocatePortReturnsOnCall = make(map[int]struct {
result1 int
result2 error
})
}
fake.allocatePortReturnsOnCall[i] = struct {
result1 int
result2 error
}{result1, result2}
}
func (fake *PortAllocator) ReleaseAllPorts(handle string) error {
fake.releaseAllPortsMutex.Lock()
ret, specificReturn := fake.releaseAllPortsReturnsOnCall[len(fake.releaseAllPortsArgsForCall)]
fake.releaseAllPortsArgsForCall = append(fake.releaseAllPortsArgsForCall, struct {
handle string
}{handle})
fake.recordInvocation("ReleaseAllPorts", []interface{}{handle})
fake.releaseAllPortsMutex.Unlock()
if fake.ReleaseAllPortsStub != nil {
return fake.ReleaseAllPortsStub(handle)
}
if specificReturn {
return ret.result1
}
return fake.releaseAllPortsReturns.result1
}
func (fake *PortAllocator) ReleaseAllPortsCallCount() int {
fake.releaseAllPortsMutex.RLock()
defer fake.releaseAllPortsMutex.RUnlock()
return len(fake.releaseAllPortsArgsForCall)
}
func (fake *PortAllocator) ReleaseAllPortsArgsForCall(i int) string {
fake.releaseAllPortsMutex.RLock()
defer fake.releaseAllPortsMutex.RUnlock()
return fake.releaseAllPortsArgsForCall[i].handle
}
func (fake *PortAllocator) ReleaseAllPortsReturns(result1 error) {
fake.ReleaseAllPortsStub = nil
fake.releaseAllPortsReturns = struct {
result1 error
}{result1}
}
func (fake *PortAllocator) ReleaseAllPortsReturnsOnCall(i int, result1 error) {
fake.ReleaseAllPortsStub = nil
if fake.releaseAllPortsReturnsOnCall == nil {
fake.releaseAllPortsReturnsOnCall = make(map[int]struct {
result1 error
})
}
fake.releaseAllPortsReturnsOnCall[i] = struct {
result1 error
}{result1}
}
func (fake *PortAllocator) Invocations() map[string][][]interface{} {
fake.invocationsMutex.RLock()
defer fake.invocationsMutex.RUnlock()
fake.allocatePortMutex.RLock()
defer fake.allocatePortMutex.RUnlock()
fake.releaseAllPortsMutex.RLock()
defer fake.releaseAllPortsMutex.RUnlock()
return fake.invocations
}
func (fake *PortAllocator) 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)
}