github.com/true-sqn/fabric@v2.1.1+incompatible/core/chaincode/mock/ledger_getter.go (about) 1 // Code generated by counterfeiter. DO NOT EDIT. 2 package mock 3 4 import ( 5 "sync" 6 7 "github.com/hyperledger/fabric/core/ledger" 8 ) 9 10 type LedgerGetter struct { 11 GetLedgerStub func(string) ledger.PeerLedger 12 getLedgerMutex sync.RWMutex 13 getLedgerArgsForCall []struct { 14 arg1 string 15 } 16 getLedgerReturns struct { 17 result1 ledger.PeerLedger 18 } 19 getLedgerReturnsOnCall map[int]struct { 20 result1 ledger.PeerLedger 21 } 22 invocations map[string][][]interface{} 23 invocationsMutex sync.RWMutex 24 } 25 26 func (fake *LedgerGetter) GetLedger(arg1 string) ledger.PeerLedger { 27 fake.getLedgerMutex.Lock() 28 ret, specificReturn := fake.getLedgerReturnsOnCall[len(fake.getLedgerArgsForCall)] 29 fake.getLedgerArgsForCall = append(fake.getLedgerArgsForCall, struct { 30 arg1 string 31 }{arg1}) 32 fake.recordInvocation("GetLedger", []interface{}{arg1}) 33 fake.getLedgerMutex.Unlock() 34 if fake.GetLedgerStub != nil { 35 return fake.GetLedgerStub(arg1) 36 } 37 if specificReturn { 38 return ret.result1 39 } 40 fakeReturns := fake.getLedgerReturns 41 return fakeReturns.result1 42 } 43 44 func (fake *LedgerGetter) GetLedgerCallCount() int { 45 fake.getLedgerMutex.RLock() 46 defer fake.getLedgerMutex.RUnlock() 47 return len(fake.getLedgerArgsForCall) 48 } 49 50 func (fake *LedgerGetter) GetLedgerCalls(stub func(string) ledger.PeerLedger) { 51 fake.getLedgerMutex.Lock() 52 defer fake.getLedgerMutex.Unlock() 53 fake.GetLedgerStub = stub 54 } 55 56 func (fake *LedgerGetter) GetLedgerArgsForCall(i int) string { 57 fake.getLedgerMutex.RLock() 58 defer fake.getLedgerMutex.RUnlock() 59 argsForCall := fake.getLedgerArgsForCall[i] 60 return argsForCall.arg1 61 } 62 63 func (fake *LedgerGetter) GetLedgerReturns(result1 ledger.PeerLedger) { 64 fake.getLedgerMutex.Lock() 65 defer fake.getLedgerMutex.Unlock() 66 fake.GetLedgerStub = nil 67 fake.getLedgerReturns = struct { 68 result1 ledger.PeerLedger 69 }{result1} 70 } 71 72 func (fake *LedgerGetter) GetLedgerReturnsOnCall(i int, result1 ledger.PeerLedger) { 73 fake.getLedgerMutex.Lock() 74 defer fake.getLedgerMutex.Unlock() 75 fake.GetLedgerStub = nil 76 if fake.getLedgerReturnsOnCall == nil { 77 fake.getLedgerReturnsOnCall = make(map[int]struct { 78 result1 ledger.PeerLedger 79 }) 80 } 81 fake.getLedgerReturnsOnCall[i] = struct { 82 result1 ledger.PeerLedger 83 }{result1} 84 } 85 86 func (fake *LedgerGetter) Invocations() map[string][][]interface{} { 87 fake.invocationsMutex.RLock() 88 defer fake.invocationsMutex.RUnlock() 89 fake.getLedgerMutex.RLock() 90 defer fake.getLedgerMutex.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 *LedgerGetter) 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 }