github.com/Thanhphan1147/cloudfoundry-cli@v7.1.0+incompatible/plugin/rpc/rpcfakes/fake_command_runner.go (about) 1 // Code generated by counterfeiter. DO NOT EDIT. 2 package rpcfakes 3 4 import ( 5 "sync" 6 7 "code.cloudfoundry.org/cli/cf/commandregistry" 8 "code.cloudfoundry.org/cli/plugin/rpc" 9 ) 10 11 type FakeCommandRunner struct { 12 CommandStub func([]string, commandregistry.Dependency, bool) error 13 commandMutex sync.RWMutex 14 commandArgsForCall []struct { 15 arg1 []string 16 arg2 commandregistry.Dependency 17 arg3 bool 18 } 19 commandReturns struct { 20 result1 error 21 } 22 commandReturnsOnCall map[int]struct { 23 result1 error 24 } 25 invocations map[string][][]interface{} 26 invocationsMutex sync.RWMutex 27 } 28 29 func (fake *FakeCommandRunner) Command(arg1 []string, arg2 commandregistry.Dependency, arg3 bool) error { 30 var arg1Copy []string 31 if arg1 != nil { 32 arg1Copy = make([]string, len(arg1)) 33 copy(arg1Copy, arg1) 34 } 35 fake.commandMutex.Lock() 36 ret, specificReturn := fake.commandReturnsOnCall[len(fake.commandArgsForCall)] 37 fake.commandArgsForCall = append(fake.commandArgsForCall, struct { 38 arg1 []string 39 arg2 commandregistry.Dependency 40 arg3 bool 41 }{arg1Copy, arg2, arg3}) 42 fake.recordInvocation("Command", []interface{}{arg1Copy, arg2, arg3}) 43 fake.commandMutex.Unlock() 44 if fake.CommandStub != nil { 45 return fake.CommandStub(arg1, arg2, arg3) 46 } 47 if specificReturn { 48 return ret.result1 49 } 50 fakeReturns := fake.commandReturns 51 return fakeReturns.result1 52 } 53 54 func (fake *FakeCommandRunner) CommandCallCount() int { 55 fake.commandMutex.RLock() 56 defer fake.commandMutex.RUnlock() 57 return len(fake.commandArgsForCall) 58 } 59 60 func (fake *FakeCommandRunner) CommandCalls(stub func([]string, commandregistry.Dependency, bool) error) { 61 fake.commandMutex.Lock() 62 defer fake.commandMutex.Unlock() 63 fake.CommandStub = stub 64 } 65 66 func (fake *FakeCommandRunner) CommandArgsForCall(i int) ([]string, commandregistry.Dependency, bool) { 67 fake.commandMutex.RLock() 68 defer fake.commandMutex.RUnlock() 69 argsForCall := fake.commandArgsForCall[i] 70 return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 71 } 72 73 func (fake *FakeCommandRunner) CommandReturns(result1 error) { 74 fake.commandMutex.Lock() 75 defer fake.commandMutex.Unlock() 76 fake.CommandStub = nil 77 fake.commandReturns = struct { 78 result1 error 79 }{result1} 80 } 81 82 func (fake *FakeCommandRunner) CommandReturnsOnCall(i int, result1 error) { 83 fake.commandMutex.Lock() 84 defer fake.commandMutex.Unlock() 85 fake.CommandStub = nil 86 if fake.commandReturnsOnCall == nil { 87 fake.commandReturnsOnCall = make(map[int]struct { 88 result1 error 89 }) 90 } 91 fake.commandReturnsOnCall[i] = struct { 92 result1 error 93 }{result1} 94 } 95 96 func (fake *FakeCommandRunner) Invocations() map[string][][]interface{} { 97 fake.invocationsMutex.RLock() 98 defer fake.invocationsMutex.RUnlock() 99 fake.commandMutex.RLock() 100 defer fake.commandMutex.RUnlock() 101 copiedInvocations := map[string][][]interface{}{} 102 for key, value := range fake.invocations { 103 copiedInvocations[key] = value 104 } 105 return copiedInvocations 106 } 107 108 func (fake *FakeCommandRunner) recordInvocation(key string, args []interface{}) { 109 fake.invocationsMutex.Lock() 110 defer fake.invocationsMutex.Unlock() 111 if fake.invocations == nil { 112 fake.invocations = map[string][][]interface{}{} 113 } 114 if fake.invocations[key] == nil { 115 fake.invocations[key] = [][]interface{}{} 116 } 117 fake.invocations[key] = append(fake.invocations[key], args) 118 } 119 120 var _ rpc.CommandRunner = new(FakeCommandRunner)