github.com/sykesm/fabric@v1.1.0-preview.0.20200129034918-2aa12b1a0181/common/deliver/mock/receiver.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 "github.com/hyperledger/fabric/common/deliver" 9 ) 10 11 type Receiver struct { 12 RecvStub func() (*common.Envelope, error) 13 recvMutex sync.RWMutex 14 recvArgsForCall []struct { 15 } 16 recvReturns struct { 17 result1 *common.Envelope 18 result2 error 19 } 20 recvReturnsOnCall map[int]struct { 21 result1 *common.Envelope 22 result2 error 23 } 24 invocations map[string][][]interface{} 25 invocationsMutex sync.RWMutex 26 } 27 28 func (fake *Receiver) Recv() (*common.Envelope, error) { 29 fake.recvMutex.Lock() 30 ret, specificReturn := fake.recvReturnsOnCall[len(fake.recvArgsForCall)] 31 fake.recvArgsForCall = append(fake.recvArgsForCall, struct { 32 }{}) 33 fake.recordInvocation("Recv", []interface{}{}) 34 fake.recvMutex.Unlock() 35 if fake.RecvStub != nil { 36 return fake.RecvStub() 37 } 38 if specificReturn { 39 return ret.result1, ret.result2 40 } 41 fakeReturns := fake.recvReturns 42 return fakeReturns.result1, fakeReturns.result2 43 } 44 45 func (fake *Receiver) RecvCallCount() int { 46 fake.recvMutex.RLock() 47 defer fake.recvMutex.RUnlock() 48 return len(fake.recvArgsForCall) 49 } 50 51 func (fake *Receiver) RecvCalls(stub func() (*common.Envelope, error)) { 52 fake.recvMutex.Lock() 53 defer fake.recvMutex.Unlock() 54 fake.RecvStub = stub 55 } 56 57 func (fake *Receiver) RecvReturns(result1 *common.Envelope, result2 error) { 58 fake.recvMutex.Lock() 59 defer fake.recvMutex.Unlock() 60 fake.RecvStub = nil 61 fake.recvReturns = struct { 62 result1 *common.Envelope 63 result2 error 64 }{result1, result2} 65 } 66 67 func (fake *Receiver) RecvReturnsOnCall(i int, result1 *common.Envelope, result2 error) { 68 fake.recvMutex.Lock() 69 defer fake.recvMutex.Unlock() 70 fake.RecvStub = nil 71 if fake.recvReturnsOnCall == nil { 72 fake.recvReturnsOnCall = make(map[int]struct { 73 result1 *common.Envelope 74 result2 error 75 }) 76 } 77 fake.recvReturnsOnCall[i] = struct { 78 result1 *common.Envelope 79 result2 error 80 }{result1, result2} 81 } 82 83 func (fake *Receiver) Invocations() map[string][][]interface{} { 84 fake.invocationsMutex.RLock() 85 defer fake.invocationsMutex.RUnlock() 86 fake.recvMutex.RLock() 87 defer fake.recvMutex.RUnlock() 88 copiedInvocations := map[string][][]interface{}{} 89 for key, value := range fake.invocations { 90 copiedInvocations[key] = value 91 } 92 return copiedInvocations 93 } 94 95 func (fake *Receiver) recordInvocation(key string, args []interface{}) { 96 fake.invocationsMutex.Lock() 97 defer fake.invocationsMutex.Unlock() 98 if fake.invocations == nil { 99 fake.invocations = map[string][][]interface{}{} 100 } 101 if fake.invocations[key] == nil { 102 fake.invocations[key] = [][]interface{}{} 103 } 104 fake.invocations[key] = append(fake.invocations[key], args) 105 } 106 107 var _ deliver.Receiver = new(Receiver)