github.com/jenspinney/cli@v6.42.1-0.20190207184520-7450c600020e+incompatible/cf/ssh/sshfakes/fake_listener_factory.go (about) 1 // This file was generated by counterfeiter 2 package sshfakes 3 4 import ( 5 "net" 6 "sync" 7 8 "code.cloudfoundry.org/cli/cf/ssh" 9 ) 10 11 type FakeListenerFactory struct { 12 ListenStub func(network, address string) (net.Listener, error) 13 listenMutex sync.RWMutex 14 listenArgsForCall []struct { 15 network string 16 address string 17 } 18 listenReturns struct { 19 result1 net.Listener 20 result2 error 21 } 22 invocations map[string][][]interface{} 23 invocationsMutex sync.RWMutex 24 } 25 26 func (fake *FakeListenerFactory) Listen(network string, address string) (net.Listener, error) { 27 fake.listenMutex.Lock() 28 fake.listenArgsForCall = append(fake.listenArgsForCall, struct { 29 network string 30 address string 31 }{network, address}) 32 fake.recordInvocation("Listen", []interface{}{network, address}) 33 fake.listenMutex.Unlock() 34 if fake.ListenStub != nil { 35 return fake.ListenStub(network, address) 36 } else { 37 return fake.listenReturns.result1, fake.listenReturns.result2 38 } 39 } 40 41 func (fake *FakeListenerFactory) ListenCallCount() int { 42 fake.listenMutex.RLock() 43 defer fake.listenMutex.RUnlock() 44 return len(fake.listenArgsForCall) 45 } 46 47 func (fake *FakeListenerFactory) ListenArgsForCall(i int) (string, string) { 48 fake.listenMutex.RLock() 49 defer fake.listenMutex.RUnlock() 50 return fake.listenArgsForCall[i].network, fake.listenArgsForCall[i].address 51 } 52 53 func (fake *FakeListenerFactory) ListenReturns(result1 net.Listener, result2 error) { 54 fake.ListenStub = nil 55 fake.listenReturns = struct { 56 result1 net.Listener 57 result2 error 58 }{result1, result2} 59 } 60 61 func (fake *FakeListenerFactory) Invocations() map[string][][]interface{} { 62 fake.invocationsMutex.RLock() 63 defer fake.invocationsMutex.RUnlock() 64 fake.listenMutex.RLock() 65 defer fake.listenMutex.RUnlock() 66 return fake.invocations 67 } 68 69 func (fake *FakeListenerFactory) recordInvocation(key string, args []interface{}) { 70 fake.invocationsMutex.Lock() 71 defer fake.invocationsMutex.Unlock() 72 if fake.invocations == nil { 73 fake.invocations = map[string][][]interface{}{} 74 } 75 if fake.invocations[key] == nil { 76 fake.invocations[key] = [][]interface{}{} 77 } 78 fake.invocations[key] = append(fake.invocations[key], args) 79 } 80 81 var _ sshCmd.ListenerFactory = new(FakeListenerFactory)