github.com/sykesm/fabric@v1.1.0-preview.0.20200129034918-2aa12b1a0181/common/deliver/mock/chain_manager.go (about) 1 // Code generated by counterfeiter. DO NOT EDIT. 2 package mock 3 4 import ( 5 "sync" 6 7 "github.com/hyperledger/fabric/common/deliver" 8 ) 9 10 type ChainManager struct { 11 GetChainStub func(string) deliver.Chain 12 getChainMutex sync.RWMutex 13 getChainArgsForCall []struct { 14 arg1 string 15 } 16 getChainReturns struct { 17 result1 deliver.Chain 18 } 19 getChainReturnsOnCall map[int]struct { 20 result1 deliver.Chain 21 } 22 invocations map[string][][]interface{} 23 invocationsMutex sync.RWMutex 24 } 25 26 func (fake *ChainManager) GetChain(arg1 string) deliver.Chain { 27 fake.getChainMutex.Lock() 28 ret, specificReturn := fake.getChainReturnsOnCall[len(fake.getChainArgsForCall)] 29 fake.getChainArgsForCall = append(fake.getChainArgsForCall, struct { 30 arg1 string 31 }{arg1}) 32 fake.recordInvocation("GetChain", []interface{}{arg1}) 33 fake.getChainMutex.Unlock() 34 if fake.GetChainStub != nil { 35 return fake.GetChainStub(arg1) 36 } 37 if specificReturn { 38 return ret.result1 39 } 40 fakeReturns := fake.getChainReturns 41 return fakeReturns.result1 42 } 43 44 func (fake *ChainManager) GetChainCallCount() int { 45 fake.getChainMutex.RLock() 46 defer fake.getChainMutex.RUnlock() 47 return len(fake.getChainArgsForCall) 48 } 49 50 func (fake *ChainManager) GetChainCalls(stub func(string) deliver.Chain) { 51 fake.getChainMutex.Lock() 52 defer fake.getChainMutex.Unlock() 53 fake.GetChainStub = stub 54 } 55 56 func (fake *ChainManager) GetChainArgsForCall(i int) string { 57 fake.getChainMutex.RLock() 58 defer fake.getChainMutex.RUnlock() 59 argsForCall := fake.getChainArgsForCall[i] 60 return argsForCall.arg1 61 } 62 63 func (fake *ChainManager) GetChainReturns(result1 deliver.Chain) { 64 fake.getChainMutex.Lock() 65 defer fake.getChainMutex.Unlock() 66 fake.GetChainStub = nil 67 fake.getChainReturns = struct { 68 result1 deliver.Chain 69 }{result1} 70 } 71 72 func (fake *ChainManager) GetChainReturnsOnCall(i int, result1 deliver.Chain) { 73 fake.getChainMutex.Lock() 74 defer fake.getChainMutex.Unlock() 75 fake.GetChainStub = nil 76 if fake.getChainReturnsOnCall == nil { 77 fake.getChainReturnsOnCall = make(map[int]struct { 78 result1 deliver.Chain 79 }) 80 } 81 fake.getChainReturnsOnCall[i] = struct { 82 result1 deliver.Chain 83 }{result1} 84 } 85 86 func (fake *ChainManager) Invocations() map[string][][]interface{} { 87 fake.invocationsMutex.RLock() 88 defer fake.invocationsMutex.RUnlock() 89 fake.getChainMutex.RLock() 90 defer fake.getChainMutex.RUnlock() 91 copiedInvocations := map[string][][]interface{}{} 92 for key, value := range fake.invocations { 93 copiedInvocations[key] = value 94 } 95 return copiedInvocations 96 } 97 98 func (fake *ChainManager) recordInvocation(key string, args []interface{}) { 99 fake.invocationsMutex.Lock() 100 defer fake.invocationsMutex.Unlock() 101 if fake.invocations == nil { 102 fake.invocations = map[string][][]interface{}{} 103 } 104 if fake.invocations[key] == nil { 105 fake.invocations[key] = [][]interface{}{} 106 } 107 fake.invocations[key] = append(fake.invocations[key], args) 108 } 109 110 var _ deliver.ChainManager = new(ChainManager)