github.com/yacovm/fabric@v2.0.0-alpha.0.20191128145320-c5d4087dc723+incompatible/core/scc/cscc/mocks/store_provider.go (about)

     1  // Code generated by counterfeiter. DO NOT EDIT.
     2  package mocks
     3  
     4  import (
     5  	"sync"
     6  
     7  	"github.com/hyperledger/fabric/core/transientstore"
     8  )
     9  
    10  type StoreProvider struct {
    11  	CloseStub        func()
    12  	closeMutex       sync.RWMutex
    13  	closeArgsForCall []struct {
    14  	}
    15  	OpenStoreStub        func(string) (*transientstore.Store, error)
    16  	openStoreMutex       sync.RWMutex
    17  	openStoreArgsForCall []struct {
    18  		arg1 string
    19  	}
    20  	openStoreReturns struct {
    21  		result1 *transientstore.Store
    22  		result2 error
    23  	}
    24  	openStoreReturnsOnCall map[int]struct {
    25  		result1 *transientstore.Store
    26  		result2 error
    27  	}
    28  	invocations      map[string][][]interface{}
    29  	invocationsMutex sync.RWMutex
    30  }
    31  
    32  func (fake *StoreProvider) Close() {
    33  	fake.closeMutex.Lock()
    34  	fake.closeArgsForCall = append(fake.closeArgsForCall, struct {
    35  	}{})
    36  	fake.recordInvocation("Close", []interface{}{})
    37  	fake.closeMutex.Unlock()
    38  	if fake.CloseStub != nil {
    39  		fake.CloseStub()
    40  	}
    41  }
    42  
    43  func (fake *StoreProvider) CloseCallCount() int {
    44  	fake.closeMutex.RLock()
    45  	defer fake.closeMutex.RUnlock()
    46  	return len(fake.closeArgsForCall)
    47  }
    48  
    49  func (fake *StoreProvider) CloseCalls(stub func()) {
    50  	fake.closeMutex.Lock()
    51  	defer fake.closeMutex.Unlock()
    52  	fake.CloseStub = stub
    53  }
    54  
    55  func (fake *StoreProvider) OpenStore(arg1 string) (*transientstore.Store, error) {
    56  	fake.openStoreMutex.Lock()
    57  	ret, specificReturn := fake.openStoreReturnsOnCall[len(fake.openStoreArgsForCall)]
    58  	fake.openStoreArgsForCall = append(fake.openStoreArgsForCall, struct {
    59  		arg1 string
    60  	}{arg1})
    61  	fake.recordInvocation("OpenStore", []interface{}{arg1})
    62  	fake.openStoreMutex.Unlock()
    63  	if fake.OpenStoreStub != nil {
    64  		return fake.OpenStoreStub(arg1)
    65  	}
    66  	if specificReturn {
    67  		return ret.result1, ret.result2
    68  	}
    69  	fakeReturns := fake.openStoreReturns
    70  	return fakeReturns.result1, fakeReturns.result2
    71  }
    72  
    73  func (fake *StoreProvider) OpenStoreCallCount() int {
    74  	fake.openStoreMutex.RLock()
    75  	defer fake.openStoreMutex.RUnlock()
    76  	return len(fake.openStoreArgsForCall)
    77  }
    78  
    79  func (fake *StoreProvider) OpenStoreCalls(stub func(string) (*transientstore.Store, error)) {
    80  	fake.openStoreMutex.Lock()
    81  	defer fake.openStoreMutex.Unlock()
    82  	fake.OpenStoreStub = stub
    83  }
    84  
    85  func (fake *StoreProvider) OpenStoreArgsForCall(i int) string {
    86  	fake.openStoreMutex.RLock()
    87  	defer fake.openStoreMutex.RUnlock()
    88  	argsForCall := fake.openStoreArgsForCall[i]
    89  	return argsForCall.arg1
    90  }
    91  
    92  func (fake *StoreProvider) OpenStoreReturns(result1 *transientstore.Store, result2 error) {
    93  	fake.openStoreMutex.Lock()
    94  	defer fake.openStoreMutex.Unlock()
    95  	fake.OpenStoreStub = nil
    96  	fake.openStoreReturns = struct {
    97  		result1 *transientstore.Store
    98  		result2 error
    99  	}{result1, result2}
   100  }
   101  
   102  func (fake *StoreProvider) OpenStoreReturnsOnCall(i int, result1 *transientstore.Store, result2 error) {
   103  	fake.openStoreMutex.Lock()
   104  	defer fake.openStoreMutex.Unlock()
   105  	fake.OpenStoreStub = nil
   106  	if fake.openStoreReturnsOnCall == nil {
   107  		fake.openStoreReturnsOnCall = make(map[int]struct {
   108  			result1 *transientstore.Store
   109  			result2 error
   110  		})
   111  	}
   112  	fake.openStoreReturnsOnCall[i] = struct {
   113  		result1 *transientstore.Store
   114  		result2 error
   115  	}{result1, result2}
   116  }
   117  
   118  func (fake *StoreProvider) Invocations() map[string][][]interface{} {
   119  	fake.invocationsMutex.RLock()
   120  	defer fake.invocationsMutex.RUnlock()
   121  	fake.closeMutex.RLock()
   122  	defer fake.closeMutex.RUnlock()
   123  	fake.openStoreMutex.RLock()
   124  	defer fake.openStoreMutex.RUnlock()
   125  	copiedInvocations := map[string][][]interface{}{}
   126  	for key, value := range fake.invocations {
   127  		copiedInvocations[key] = value
   128  	}
   129  	return copiedInvocations
   130  }
   131  
   132  func (fake *StoreProvider) recordInvocation(key string, args []interface{}) {
   133  	fake.invocationsMutex.Lock()
   134  	defer fake.invocationsMutex.Unlock()
   135  	if fake.invocations == nil {
   136  		fake.invocations = map[string][][]interface{}{}
   137  	}
   138  	if fake.invocations[key] == nil {
   139  		fake.invocations[key] = [][]interface{}{}
   140  	}
   141  	fake.invocations[key] = append(fake.invocations[key], args)
   142  }