github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/cf/api/securitygroups/securitygroupsfakes/fake_security_group_repo.go (about) 1 // This file was generated by counterfeiter 2 package securitygroupsfakes 3 4 import ( 5 "sync" 6 7 "code.cloudfoundry.org/cli/cf/api/securitygroups" 8 "code.cloudfoundry.org/cli/cf/models" 9 ) 10 11 type FakeSecurityGroupRepo struct { 12 CreateStub func(name string, rules []map[string]interface{}) error 13 createMutex sync.RWMutex 14 createArgsForCall []struct { 15 name string 16 rules []map[string]interface{} 17 } 18 createReturns struct { 19 result1 error 20 } 21 UpdateStub func(guid string, rules []map[string]interface{}) error 22 updateMutex sync.RWMutex 23 updateArgsForCall []struct { 24 guid string 25 rules []map[string]interface{} 26 } 27 updateReturns struct { 28 result1 error 29 } 30 ReadStub func(string) (models.SecurityGroup, error) 31 readMutex sync.RWMutex 32 readArgsForCall []struct { 33 arg1 string 34 } 35 readReturns struct { 36 result1 models.SecurityGroup 37 result2 error 38 } 39 DeleteStub func(string) error 40 deleteMutex sync.RWMutex 41 deleteArgsForCall []struct { 42 arg1 string 43 } 44 deleteReturns struct { 45 result1 error 46 } 47 FindAllStub func() ([]models.SecurityGroup, error) 48 findAllMutex sync.RWMutex 49 findAllArgsForCall []struct{} 50 findAllReturns struct { 51 result1 []models.SecurityGroup 52 result2 error 53 } 54 invocations map[string][][]interface{} 55 invocationsMutex sync.RWMutex 56 } 57 58 func (fake *FakeSecurityGroupRepo) Create(name string, rules []map[string]interface{}) error { 59 var rulesCopy []map[string]interface{} 60 if rules != nil { 61 rulesCopy = make([]map[string]interface{}, len(rules)) 62 copy(rulesCopy, rules) 63 } 64 fake.createMutex.Lock() 65 fake.createArgsForCall = append(fake.createArgsForCall, struct { 66 name string 67 rules []map[string]interface{} 68 }{name, rulesCopy}) 69 fake.recordInvocation("Create", []interface{}{name, rulesCopy}) 70 fake.createMutex.Unlock() 71 if fake.CreateStub != nil { 72 return fake.CreateStub(name, rules) 73 } else { 74 return fake.createReturns.result1 75 } 76 } 77 78 func (fake *FakeSecurityGroupRepo) CreateCallCount() int { 79 fake.createMutex.RLock() 80 defer fake.createMutex.RUnlock() 81 return len(fake.createArgsForCall) 82 } 83 84 func (fake *FakeSecurityGroupRepo) CreateArgsForCall(i int) (string, []map[string]interface{}) { 85 fake.createMutex.RLock() 86 defer fake.createMutex.RUnlock() 87 return fake.createArgsForCall[i].name, fake.createArgsForCall[i].rules 88 } 89 90 func (fake *FakeSecurityGroupRepo) CreateReturns(result1 error) { 91 fake.CreateStub = nil 92 fake.createReturns = struct { 93 result1 error 94 }{result1} 95 } 96 97 func (fake *FakeSecurityGroupRepo) Update(guid string, rules []map[string]interface{}) error { 98 var rulesCopy []map[string]interface{} 99 if rules != nil { 100 rulesCopy = make([]map[string]interface{}, len(rules)) 101 copy(rulesCopy, rules) 102 } 103 fake.updateMutex.Lock() 104 fake.updateArgsForCall = append(fake.updateArgsForCall, struct { 105 guid string 106 rules []map[string]interface{} 107 }{guid, rulesCopy}) 108 fake.recordInvocation("Update", []interface{}{guid, rulesCopy}) 109 fake.updateMutex.Unlock() 110 if fake.UpdateStub != nil { 111 return fake.UpdateStub(guid, rules) 112 } else { 113 return fake.updateReturns.result1 114 } 115 } 116 117 func (fake *FakeSecurityGroupRepo) UpdateCallCount() int { 118 fake.updateMutex.RLock() 119 defer fake.updateMutex.RUnlock() 120 return len(fake.updateArgsForCall) 121 } 122 123 func (fake *FakeSecurityGroupRepo) UpdateArgsForCall(i int) (string, []map[string]interface{}) { 124 fake.updateMutex.RLock() 125 defer fake.updateMutex.RUnlock() 126 return fake.updateArgsForCall[i].guid, fake.updateArgsForCall[i].rules 127 } 128 129 func (fake *FakeSecurityGroupRepo) UpdateReturns(result1 error) { 130 fake.UpdateStub = nil 131 fake.updateReturns = struct { 132 result1 error 133 }{result1} 134 } 135 136 func (fake *FakeSecurityGroupRepo) Read(arg1 string) (models.SecurityGroup, error) { 137 fake.readMutex.Lock() 138 fake.readArgsForCall = append(fake.readArgsForCall, struct { 139 arg1 string 140 }{arg1}) 141 fake.recordInvocation("Read", []interface{}{arg1}) 142 fake.readMutex.Unlock() 143 if fake.ReadStub != nil { 144 return fake.ReadStub(arg1) 145 } else { 146 return fake.readReturns.result1, fake.readReturns.result2 147 } 148 } 149 150 func (fake *FakeSecurityGroupRepo) ReadCallCount() int { 151 fake.readMutex.RLock() 152 defer fake.readMutex.RUnlock() 153 return len(fake.readArgsForCall) 154 } 155 156 func (fake *FakeSecurityGroupRepo) ReadArgsForCall(i int) string { 157 fake.readMutex.RLock() 158 defer fake.readMutex.RUnlock() 159 return fake.readArgsForCall[i].arg1 160 } 161 162 func (fake *FakeSecurityGroupRepo) ReadReturns(result1 models.SecurityGroup, result2 error) { 163 fake.ReadStub = nil 164 fake.readReturns = struct { 165 result1 models.SecurityGroup 166 result2 error 167 }{result1, result2} 168 } 169 170 func (fake *FakeSecurityGroupRepo) Delete(arg1 string) error { 171 fake.deleteMutex.Lock() 172 fake.deleteArgsForCall = append(fake.deleteArgsForCall, struct { 173 arg1 string 174 }{arg1}) 175 fake.recordInvocation("Delete", []interface{}{arg1}) 176 fake.deleteMutex.Unlock() 177 if fake.DeleteStub != nil { 178 return fake.DeleteStub(arg1) 179 } else { 180 return fake.deleteReturns.result1 181 } 182 } 183 184 func (fake *FakeSecurityGroupRepo) DeleteCallCount() int { 185 fake.deleteMutex.RLock() 186 defer fake.deleteMutex.RUnlock() 187 return len(fake.deleteArgsForCall) 188 } 189 190 func (fake *FakeSecurityGroupRepo) DeleteArgsForCall(i int) string { 191 fake.deleteMutex.RLock() 192 defer fake.deleteMutex.RUnlock() 193 return fake.deleteArgsForCall[i].arg1 194 } 195 196 func (fake *FakeSecurityGroupRepo) DeleteReturns(result1 error) { 197 fake.DeleteStub = nil 198 fake.deleteReturns = struct { 199 result1 error 200 }{result1} 201 } 202 203 func (fake *FakeSecurityGroupRepo) FindAll() ([]models.SecurityGroup, error) { 204 fake.findAllMutex.Lock() 205 fake.findAllArgsForCall = append(fake.findAllArgsForCall, struct{}{}) 206 fake.recordInvocation("FindAll", []interface{}{}) 207 fake.findAllMutex.Unlock() 208 if fake.FindAllStub != nil { 209 return fake.FindAllStub() 210 } else { 211 return fake.findAllReturns.result1, fake.findAllReturns.result2 212 } 213 } 214 215 func (fake *FakeSecurityGroupRepo) FindAllCallCount() int { 216 fake.findAllMutex.RLock() 217 defer fake.findAllMutex.RUnlock() 218 return len(fake.findAllArgsForCall) 219 } 220 221 func (fake *FakeSecurityGroupRepo) FindAllReturns(result1 []models.SecurityGroup, result2 error) { 222 fake.FindAllStub = nil 223 fake.findAllReturns = struct { 224 result1 []models.SecurityGroup 225 result2 error 226 }{result1, result2} 227 } 228 229 func (fake *FakeSecurityGroupRepo) Invocations() map[string][][]interface{} { 230 fake.invocationsMutex.RLock() 231 defer fake.invocationsMutex.RUnlock() 232 fake.createMutex.RLock() 233 defer fake.createMutex.RUnlock() 234 fake.updateMutex.RLock() 235 defer fake.updateMutex.RUnlock() 236 fake.readMutex.RLock() 237 defer fake.readMutex.RUnlock() 238 fake.deleteMutex.RLock() 239 defer fake.deleteMutex.RUnlock() 240 fake.findAllMutex.RLock() 241 defer fake.findAllMutex.RUnlock() 242 return fake.invocations 243 } 244 245 func (fake *FakeSecurityGroupRepo) recordInvocation(key string, args []interface{}) { 246 fake.invocationsMutex.Lock() 247 defer fake.invocationsMutex.Unlock() 248 if fake.invocations == nil { 249 fake.invocations = map[string][][]interface{}{} 250 } 251 if fake.invocations[key] == nil { 252 fake.invocations[key] = [][]interface{}{} 253 } 254 fake.invocations[key] = append(fake.invocations[key], args) 255 } 256 257 var _ securitygroups.SecurityGroupRepo = new(FakeSecurityGroupRepo)