forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fake_listener_factory.go
81 lines (71 loc) · 2.16 KB
/
fake_listener_factory.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
// This file was generated by counterfeiter
package sshfakes
import (
"net"
"sync"
"code.cloudfoundry.org/cli/cf/ssh"
)
type FakeListenerFactory struct {
ListenStub func(network, address string) (net.Listener, error)
listenMutex sync.RWMutex
listenArgsForCall []struct {
network string
address string
}
listenReturns struct {
result1 net.Listener
result2 error
}
invocations map[string][][]interface{}
invocationsMutex sync.RWMutex
}
func (fake *FakeListenerFactory) Listen(network string, address string) (net.Listener, error) {
fake.listenMutex.Lock()
fake.listenArgsForCall = append(fake.listenArgsForCall, struct {
network string
address string
}{network, address})
fake.recordInvocation("Listen", []interface{}{network, address})
fake.listenMutex.Unlock()
if fake.ListenStub != nil {
return fake.ListenStub(network, address)
} else {
return fake.listenReturns.result1, fake.listenReturns.result2
}
}
func (fake *FakeListenerFactory) ListenCallCount() int {
fake.listenMutex.RLock()
defer fake.listenMutex.RUnlock()
return len(fake.listenArgsForCall)
}
func (fake *FakeListenerFactory) ListenArgsForCall(i int) (string, string) {
fake.listenMutex.RLock()
defer fake.listenMutex.RUnlock()
return fake.listenArgsForCall[i].network, fake.listenArgsForCall[i].address
}
func (fake *FakeListenerFactory) ListenReturns(result1 net.Listener, result2 error) {
fake.ListenStub = nil
fake.listenReturns = struct {
result1 net.Listener
result2 error
}{result1, result2}
}
func (fake *FakeListenerFactory) Invocations() map[string][][]interface{} {
fake.invocationsMutex.RLock()
defer fake.invocationsMutex.RUnlock()
fake.listenMutex.RLock()
defer fake.listenMutex.RUnlock()
return fake.invocations
}
func (fake *FakeListenerFactory) 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 _ sshCmd.ListenerFactory = new(FakeListenerFactory)