github.com/sykesm/fabric@v1.1.0-preview.0.20200129034918-2aa12b1a0181/common/deliver/mock/block_iterator.go (about) 1 // Code generated by counterfeiter. DO NOT EDIT. 2 package mock 3 4 import ( 5 "sync" 6 7 "github.com/hyperledger/fabric-protos-go/common" 8 ) 9 10 type BlockIterator struct { 11 CloseStub func() 12 closeMutex sync.RWMutex 13 closeArgsForCall []struct { 14 } 15 NextStub func() (*common.Block, common.Status) 16 nextMutex sync.RWMutex 17 nextArgsForCall []struct { 18 } 19 nextReturns struct { 20 result1 *common.Block 21 result2 common.Status 22 } 23 nextReturnsOnCall map[int]struct { 24 result1 *common.Block 25 result2 common.Status 26 } 27 invocations map[string][][]interface{} 28 invocationsMutex sync.RWMutex 29 } 30 31 func (fake *BlockIterator) Close() { 32 fake.closeMutex.Lock() 33 fake.closeArgsForCall = append(fake.closeArgsForCall, struct { 34 }{}) 35 fake.recordInvocation("Close", []interface{}{}) 36 fake.closeMutex.Unlock() 37 if fake.CloseStub != nil { 38 fake.CloseStub() 39 } 40 } 41 42 func (fake *BlockIterator) CloseCallCount() int { 43 fake.closeMutex.RLock() 44 defer fake.closeMutex.RUnlock() 45 return len(fake.closeArgsForCall) 46 } 47 48 func (fake *BlockIterator) CloseCalls(stub func()) { 49 fake.closeMutex.Lock() 50 defer fake.closeMutex.Unlock() 51 fake.CloseStub = stub 52 } 53 54 func (fake *BlockIterator) Next() (*common.Block, common.Status) { 55 fake.nextMutex.Lock() 56 ret, specificReturn := fake.nextReturnsOnCall[len(fake.nextArgsForCall)] 57 fake.nextArgsForCall = append(fake.nextArgsForCall, struct { 58 }{}) 59 fake.recordInvocation("Next", []interface{}{}) 60 fake.nextMutex.Unlock() 61 if fake.NextStub != nil { 62 return fake.NextStub() 63 } 64 if specificReturn { 65 return ret.result1, ret.result2 66 } 67 fakeReturns := fake.nextReturns 68 return fakeReturns.result1, fakeReturns.result2 69 } 70 71 func (fake *BlockIterator) NextCallCount() int { 72 fake.nextMutex.RLock() 73 defer fake.nextMutex.RUnlock() 74 return len(fake.nextArgsForCall) 75 } 76 77 func (fake *BlockIterator) NextCalls(stub func() (*common.Block, common.Status)) { 78 fake.nextMutex.Lock() 79 defer fake.nextMutex.Unlock() 80 fake.NextStub = stub 81 } 82 83 func (fake *BlockIterator) NextReturns(result1 *common.Block, result2 common.Status) { 84 fake.nextMutex.Lock() 85 defer fake.nextMutex.Unlock() 86 fake.NextStub = nil 87 fake.nextReturns = struct { 88 result1 *common.Block 89 result2 common.Status 90 }{result1, result2} 91 } 92 93 func (fake *BlockIterator) NextReturnsOnCall(i int, result1 *common.Block, result2 common.Status) { 94 fake.nextMutex.Lock() 95 defer fake.nextMutex.Unlock() 96 fake.NextStub = nil 97 if fake.nextReturnsOnCall == nil { 98 fake.nextReturnsOnCall = make(map[int]struct { 99 result1 *common.Block 100 result2 common.Status 101 }) 102 } 103 fake.nextReturnsOnCall[i] = struct { 104 result1 *common.Block 105 result2 common.Status 106 }{result1, result2} 107 } 108 109 func (fake *BlockIterator) Invocations() map[string][][]interface{} { 110 fake.invocationsMutex.RLock() 111 defer fake.invocationsMutex.RUnlock() 112 fake.closeMutex.RLock() 113 defer fake.closeMutex.RUnlock() 114 fake.nextMutex.RLock() 115 defer fake.nextMutex.RUnlock() 116 copiedInvocations := map[string][][]interface{}{} 117 for key, value := range fake.invocations { 118 copiedInvocations[key] = value 119 } 120 return copiedInvocations 121 } 122 123 func (fake *BlockIterator) recordInvocation(key string, args []interface{}) { 124 fake.invocationsMutex.Lock() 125 defer fake.invocationsMutex.Unlock() 126 if fake.invocations == nil { 127 fake.invocations = map[string][][]interface{}{} 128 } 129 if fake.invocations[key] == nil { 130 fake.invocations[key] = [][]interface{}{} 131 } 132 fake.invocations[key] = append(fake.invocations[key], args) 133 }