github.com/lzy4123/fabric@v2.1.1+incompatible/core/chaincode/persistence/mock/ioreadwriter.go (about) 1 // Code generated by counterfeiter. DO NOT EDIT. 2 package mock 3 4 import ( 5 "os" 6 "sync" 7 ) 8 9 type IOReadWriter struct { 10 ExistsStub func(string) (bool, error) 11 existsMutex sync.RWMutex 12 existsArgsForCall []struct { 13 arg1 string 14 } 15 existsReturns struct { 16 result1 bool 17 result2 error 18 } 19 existsReturnsOnCall map[int]struct { 20 result1 bool 21 result2 error 22 } 23 MakeDirStub func(string, os.FileMode) error 24 makeDirMutex sync.RWMutex 25 makeDirArgsForCall []struct { 26 arg1 string 27 arg2 os.FileMode 28 } 29 makeDirReturns struct { 30 result1 error 31 } 32 makeDirReturnsOnCall map[int]struct { 33 result1 error 34 } 35 ReadDirStub func(string) ([]os.FileInfo, error) 36 readDirMutex sync.RWMutex 37 readDirArgsForCall []struct { 38 arg1 string 39 } 40 readDirReturns struct { 41 result1 []os.FileInfo 42 result2 error 43 } 44 readDirReturnsOnCall map[int]struct { 45 result1 []os.FileInfo 46 result2 error 47 } 48 ReadFileStub func(string) ([]byte, error) 49 readFileMutex sync.RWMutex 50 readFileArgsForCall []struct { 51 arg1 string 52 } 53 readFileReturns struct { 54 result1 []byte 55 result2 error 56 } 57 readFileReturnsOnCall map[int]struct { 58 result1 []byte 59 result2 error 60 } 61 RemoveStub func(string) error 62 removeMutex sync.RWMutex 63 removeArgsForCall []struct { 64 arg1 string 65 } 66 removeReturns struct { 67 result1 error 68 } 69 removeReturnsOnCall map[int]struct { 70 result1 error 71 } 72 WriteFileStub func(string, string, []byte) error 73 writeFileMutex sync.RWMutex 74 writeFileArgsForCall []struct { 75 arg1 string 76 arg2 string 77 arg3 []byte 78 } 79 writeFileReturns struct { 80 result1 error 81 } 82 writeFileReturnsOnCall map[int]struct { 83 result1 error 84 } 85 invocations map[string][][]interface{} 86 invocationsMutex sync.RWMutex 87 } 88 89 func (fake *IOReadWriter) Exists(arg1 string) (bool, error) { 90 fake.existsMutex.Lock() 91 ret, specificReturn := fake.existsReturnsOnCall[len(fake.existsArgsForCall)] 92 fake.existsArgsForCall = append(fake.existsArgsForCall, struct { 93 arg1 string 94 }{arg1}) 95 fake.recordInvocation("Exists", []interface{}{arg1}) 96 fake.existsMutex.Unlock() 97 if fake.ExistsStub != nil { 98 return fake.ExistsStub(arg1) 99 } 100 if specificReturn { 101 return ret.result1, ret.result2 102 } 103 fakeReturns := fake.existsReturns 104 return fakeReturns.result1, fakeReturns.result2 105 } 106 107 func (fake *IOReadWriter) ExistsCallCount() int { 108 fake.existsMutex.RLock() 109 defer fake.existsMutex.RUnlock() 110 return len(fake.existsArgsForCall) 111 } 112 113 func (fake *IOReadWriter) ExistsCalls(stub func(string) (bool, error)) { 114 fake.existsMutex.Lock() 115 defer fake.existsMutex.Unlock() 116 fake.ExistsStub = stub 117 } 118 119 func (fake *IOReadWriter) ExistsArgsForCall(i int) string { 120 fake.existsMutex.RLock() 121 defer fake.existsMutex.RUnlock() 122 argsForCall := fake.existsArgsForCall[i] 123 return argsForCall.arg1 124 } 125 126 func (fake *IOReadWriter) ExistsReturns(result1 bool, result2 error) { 127 fake.existsMutex.Lock() 128 defer fake.existsMutex.Unlock() 129 fake.ExistsStub = nil 130 fake.existsReturns = struct { 131 result1 bool 132 result2 error 133 }{result1, result2} 134 } 135 136 func (fake *IOReadWriter) ExistsReturnsOnCall(i int, result1 bool, result2 error) { 137 fake.existsMutex.Lock() 138 defer fake.existsMutex.Unlock() 139 fake.ExistsStub = nil 140 if fake.existsReturnsOnCall == nil { 141 fake.existsReturnsOnCall = make(map[int]struct { 142 result1 bool 143 result2 error 144 }) 145 } 146 fake.existsReturnsOnCall[i] = struct { 147 result1 bool 148 result2 error 149 }{result1, result2} 150 } 151 152 func (fake *IOReadWriter) MakeDir(arg1 string, arg2 os.FileMode) error { 153 fake.makeDirMutex.Lock() 154 ret, specificReturn := fake.makeDirReturnsOnCall[len(fake.makeDirArgsForCall)] 155 fake.makeDirArgsForCall = append(fake.makeDirArgsForCall, struct { 156 arg1 string 157 arg2 os.FileMode 158 }{arg1, arg2}) 159 fake.recordInvocation("MakeDir", []interface{}{arg1, arg2}) 160 fake.makeDirMutex.Unlock() 161 if fake.MakeDirStub != nil { 162 return fake.MakeDirStub(arg1, arg2) 163 } 164 if specificReturn { 165 return ret.result1 166 } 167 fakeReturns := fake.makeDirReturns 168 return fakeReturns.result1 169 } 170 171 func (fake *IOReadWriter) MakeDirCallCount() int { 172 fake.makeDirMutex.RLock() 173 defer fake.makeDirMutex.RUnlock() 174 return len(fake.makeDirArgsForCall) 175 } 176 177 func (fake *IOReadWriter) MakeDirCalls(stub func(string, os.FileMode) error) { 178 fake.makeDirMutex.Lock() 179 defer fake.makeDirMutex.Unlock() 180 fake.MakeDirStub = stub 181 } 182 183 func (fake *IOReadWriter) MakeDirArgsForCall(i int) (string, os.FileMode) { 184 fake.makeDirMutex.RLock() 185 defer fake.makeDirMutex.RUnlock() 186 argsForCall := fake.makeDirArgsForCall[i] 187 return argsForCall.arg1, argsForCall.arg2 188 } 189 190 func (fake *IOReadWriter) MakeDirReturns(result1 error) { 191 fake.makeDirMutex.Lock() 192 defer fake.makeDirMutex.Unlock() 193 fake.MakeDirStub = nil 194 fake.makeDirReturns = struct { 195 result1 error 196 }{result1} 197 } 198 199 func (fake *IOReadWriter) MakeDirReturnsOnCall(i int, result1 error) { 200 fake.makeDirMutex.Lock() 201 defer fake.makeDirMutex.Unlock() 202 fake.MakeDirStub = nil 203 if fake.makeDirReturnsOnCall == nil { 204 fake.makeDirReturnsOnCall = make(map[int]struct { 205 result1 error 206 }) 207 } 208 fake.makeDirReturnsOnCall[i] = struct { 209 result1 error 210 }{result1} 211 } 212 213 func (fake *IOReadWriter) ReadDir(arg1 string) ([]os.FileInfo, error) { 214 fake.readDirMutex.Lock() 215 ret, specificReturn := fake.readDirReturnsOnCall[len(fake.readDirArgsForCall)] 216 fake.readDirArgsForCall = append(fake.readDirArgsForCall, struct { 217 arg1 string 218 }{arg1}) 219 fake.recordInvocation("ReadDir", []interface{}{arg1}) 220 fake.readDirMutex.Unlock() 221 if fake.ReadDirStub != nil { 222 return fake.ReadDirStub(arg1) 223 } 224 if specificReturn { 225 return ret.result1, ret.result2 226 } 227 fakeReturns := fake.readDirReturns 228 return fakeReturns.result1, fakeReturns.result2 229 } 230 231 func (fake *IOReadWriter) ReadDirCallCount() int { 232 fake.readDirMutex.RLock() 233 defer fake.readDirMutex.RUnlock() 234 return len(fake.readDirArgsForCall) 235 } 236 237 func (fake *IOReadWriter) ReadDirCalls(stub func(string) ([]os.FileInfo, error)) { 238 fake.readDirMutex.Lock() 239 defer fake.readDirMutex.Unlock() 240 fake.ReadDirStub = stub 241 } 242 243 func (fake *IOReadWriter) ReadDirArgsForCall(i int) string { 244 fake.readDirMutex.RLock() 245 defer fake.readDirMutex.RUnlock() 246 argsForCall := fake.readDirArgsForCall[i] 247 return argsForCall.arg1 248 } 249 250 func (fake *IOReadWriter) ReadDirReturns(result1 []os.FileInfo, result2 error) { 251 fake.readDirMutex.Lock() 252 defer fake.readDirMutex.Unlock() 253 fake.ReadDirStub = nil 254 fake.readDirReturns = struct { 255 result1 []os.FileInfo 256 result2 error 257 }{result1, result2} 258 } 259 260 func (fake *IOReadWriter) ReadDirReturnsOnCall(i int, result1 []os.FileInfo, result2 error) { 261 fake.readDirMutex.Lock() 262 defer fake.readDirMutex.Unlock() 263 fake.ReadDirStub = nil 264 if fake.readDirReturnsOnCall == nil { 265 fake.readDirReturnsOnCall = make(map[int]struct { 266 result1 []os.FileInfo 267 result2 error 268 }) 269 } 270 fake.readDirReturnsOnCall[i] = struct { 271 result1 []os.FileInfo 272 result2 error 273 }{result1, result2} 274 } 275 276 func (fake *IOReadWriter) ReadFile(arg1 string) ([]byte, error) { 277 fake.readFileMutex.Lock() 278 ret, specificReturn := fake.readFileReturnsOnCall[len(fake.readFileArgsForCall)] 279 fake.readFileArgsForCall = append(fake.readFileArgsForCall, struct { 280 arg1 string 281 }{arg1}) 282 fake.recordInvocation("ReadFile", []interface{}{arg1}) 283 fake.readFileMutex.Unlock() 284 if fake.ReadFileStub != nil { 285 return fake.ReadFileStub(arg1) 286 } 287 if specificReturn { 288 return ret.result1, ret.result2 289 } 290 fakeReturns := fake.readFileReturns 291 return fakeReturns.result1, fakeReturns.result2 292 } 293 294 func (fake *IOReadWriter) ReadFileCallCount() int { 295 fake.readFileMutex.RLock() 296 defer fake.readFileMutex.RUnlock() 297 return len(fake.readFileArgsForCall) 298 } 299 300 func (fake *IOReadWriter) ReadFileCalls(stub func(string) ([]byte, error)) { 301 fake.readFileMutex.Lock() 302 defer fake.readFileMutex.Unlock() 303 fake.ReadFileStub = stub 304 } 305 306 func (fake *IOReadWriter) ReadFileArgsForCall(i int) string { 307 fake.readFileMutex.RLock() 308 defer fake.readFileMutex.RUnlock() 309 argsForCall := fake.readFileArgsForCall[i] 310 return argsForCall.arg1 311 } 312 313 func (fake *IOReadWriter) ReadFileReturns(result1 []byte, result2 error) { 314 fake.readFileMutex.Lock() 315 defer fake.readFileMutex.Unlock() 316 fake.ReadFileStub = nil 317 fake.readFileReturns = struct { 318 result1 []byte 319 result2 error 320 }{result1, result2} 321 } 322 323 func (fake *IOReadWriter) ReadFileReturnsOnCall(i int, result1 []byte, result2 error) { 324 fake.readFileMutex.Lock() 325 defer fake.readFileMutex.Unlock() 326 fake.ReadFileStub = nil 327 if fake.readFileReturnsOnCall == nil { 328 fake.readFileReturnsOnCall = make(map[int]struct { 329 result1 []byte 330 result2 error 331 }) 332 } 333 fake.readFileReturnsOnCall[i] = struct { 334 result1 []byte 335 result2 error 336 }{result1, result2} 337 } 338 339 func (fake *IOReadWriter) Remove(arg1 string) error { 340 fake.removeMutex.Lock() 341 ret, specificReturn := fake.removeReturnsOnCall[len(fake.removeArgsForCall)] 342 fake.removeArgsForCall = append(fake.removeArgsForCall, struct { 343 arg1 string 344 }{arg1}) 345 fake.recordInvocation("Remove", []interface{}{arg1}) 346 fake.removeMutex.Unlock() 347 if fake.RemoveStub != nil { 348 return fake.RemoveStub(arg1) 349 } 350 if specificReturn { 351 return ret.result1 352 } 353 fakeReturns := fake.removeReturns 354 return fakeReturns.result1 355 } 356 357 func (fake *IOReadWriter) RemoveCallCount() int { 358 fake.removeMutex.RLock() 359 defer fake.removeMutex.RUnlock() 360 return len(fake.removeArgsForCall) 361 } 362 363 func (fake *IOReadWriter) RemoveCalls(stub func(string) error) { 364 fake.removeMutex.Lock() 365 defer fake.removeMutex.Unlock() 366 fake.RemoveStub = stub 367 } 368 369 func (fake *IOReadWriter) RemoveArgsForCall(i int) string { 370 fake.removeMutex.RLock() 371 defer fake.removeMutex.RUnlock() 372 argsForCall := fake.removeArgsForCall[i] 373 return argsForCall.arg1 374 } 375 376 func (fake *IOReadWriter) RemoveReturns(result1 error) { 377 fake.removeMutex.Lock() 378 defer fake.removeMutex.Unlock() 379 fake.RemoveStub = nil 380 fake.removeReturns = struct { 381 result1 error 382 }{result1} 383 } 384 385 func (fake *IOReadWriter) RemoveReturnsOnCall(i int, result1 error) { 386 fake.removeMutex.Lock() 387 defer fake.removeMutex.Unlock() 388 fake.RemoveStub = nil 389 if fake.removeReturnsOnCall == nil { 390 fake.removeReturnsOnCall = make(map[int]struct { 391 result1 error 392 }) 393 } 394 fake.removeReturnsOnCall[i] = struct { 395 result1 error 396 }{result1} 397 } 398 399 func (fake *IOReadWriter) WriteFile(arg1 string, arg2 string, arg3 []byte) error { 400 var arg3Copy []byte 401 if arg3 != nil { 402 arg3Copy = make([]byte, len(arg3)) 403 copy(arg3Copy, arg3) 404 } 405 fake.writeFileMutex.Lock() 406 ret, specificReturn := fake.writeFileReturnsOnCall[len(fake.writeFileArgsForCall)] 407 fake.writeFileArgsForCall = append(fake.writeFileArgsForCall, struct { 408 arg1 string 409 arg2 string 410 arg3 []byte 411 }{arg1, arg2, arg3Copy}) 412 fake.recordInvocation("WriteFile", []interface{}{arg1, arg2, arg3Copy}) 413 fake.writeFileMutex.Unlock() 414 if fake.WriteFileStub != nil { 415 return fake.WriteFileStub(arg1, arg2, arg3) 416 } 417 if specificReturn { 418 return ret.result1 419 } 420 fakeReturns := fake.writeFileReturns 421 return fakeReturns.result1 422 } 423 424 func (fake *IOReadWriter) WriteFileCallCount() int { 425 fake.writeFileMutex.RLock() 426 defer fake.writeFileMutex.RUnlock() 427 return len(fake.writeFileArgsForCall) 428 } 429 430 func (fake *IOReadWriter) WriteFileCalls(stub func(string, string, []byte) error) { 431 fake.writeFileMutex.Lock() 432 defer fake.writeFileMutex.Unlock() 433 fake.WriteFileStub = stub 434 } 435 436 func (fake *IOReadWriter) WriteFileArgsForCall(i int) (string, string, []byte) { 437 fake.writeFileMutex.RLock() 438 defer fake.writeFileMutex.RUnlock() 439 argsForCall := fake.writeFileArgsForCall[i] 440 return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 441 } 442 443 func (fake *IOReadWriter) WriteFileReturns(result1 error) { 444 fake.writeFileMutex.Lock() 445 defer fake.writeFileMutex.Unlock() 446 fake.WriteFileStub = nil 447 fake.writeFileReturns = struct { 448 result1 error 449 }{result1} 450 } 451 452 func (fake *IOReadWriter) WriteFileReturnsOnCall(i int, result1 error) { 453 fake.writeFileMutex.Lock() 454 defer fake.writeFileMutex.Unlock() 455 fake.WriteFileStub = nil 456 if fake.writeFileReturnsOnCall == nil { 457 fake.writeFileReturnsOnCall = make(map[int]struct { 458 result1 error 459 }) 460 } 461 fake.writeFileReturnsOnCall[i] = struct { 462 result1 error 463 }{result1} 464 } 465 466 func (fake *IOReadWriter) Invocations() map[string][][]interface{} { 467 fake.invocationsMutex.RLock() 468 defer fake.invocationsMutex.RUnlock() 469 fake.existsMutex.RLock() 470 defer fake.existsMutex.RUnlock() 471 fake.makeDirMutex.RLock() 472 defer fake.makeDirMutex.RUnlock() 473 fake.readDirMutex.RLock() 474 defer fake.readDirMutex.RUnlock() 475 fake.readFileMutex.RLock() 476 defer fake.readFileMutex.RUnlock() 477 fake.removeMutex.RLock() 478 defer fake.removeMutex.RUnlock() 479 fake.writeFileMutex.RLock() 480 defer fake.writeFileMutex.RUnlock() 481 copiedInvocations := map[string][][]interface{}{} 482 for key, value := range fake.invocations { 483 copiedInvocations[key] = value 484 } 485 return copiedInvocations 486 } 487 488 func (fake *IOReadWriter) recordInvocation(key string, args []interface{}) { 489 fake.invocationsMutex.Lock() 490 defer fake.invocationsMutex.Unlock() 491 if fake.invocations == nil { 492 fake.invocations = map[string][][]interface{}{} 493 } 494 if fake.invocations[key] == nil { 495 fake.invocations[key] = [][]interface{}{} 496 } 497 fake.invocations[key] = append(fake.invocations[key], args) 498 }