github.com/hyperledger-labs/bdls@v2.1.1+incompatible/core/chaincode/lifecycle/mock/package_parser.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/chaincode/persistence"
     8  )
     9  
    10  type PackageParser struct {
    11  	ParseStub        func([]byte) (*persistence.ChaincodePackage, error)
    12  	parseMutex       sync.RWMutex
    13  	parseArgsForCall []struct {
    14  		arg1 []byte
    15  	}
    16  	parseReturns struct {
    17  		result1 *persistence.ChaincodePackage
    18  		result2 error
    19  	}
    20  	parseReturnsOnCall map[int]struct {
    21  		result1 *persistence.ChaincodePackage
    22  		result2 error
    23  	}
    24  	invocations      map[string][][]interface{}
    25  	invocationsMutex sync.RWMutex
    26  }
    27  
    28  func (fake *PackageParser) Parse(arg1 []byte) (*persistence.ChaincodePackage, error) {
    29  	var arg1Copy []byte
    30  	if arg1 != nil {
    31  		arg1Copy = make([]byte, len(arg1))
    32  		copy(arg1Copy, arg1)
    33  	}
    34  	fake.parseMutex.Lock()
    35  	ret, specificReturn := fake.parseReturnsOnCall[len(fake.parseArgsForCall)]
    36  	fake.parseArgsForCall = append(fake.parseArgsForCall, struct {
    37  		arg1 []byte
    38  	}{arg1Copy})
    39  	fake.recordInvocation("Parse", []interface{}{arg1Copy})
    40  	fake.parseMutex.Unlock()
    41  	if fake.ParseStub != nil {
    42  		return fake.ParseStub(arg1)
    43  	}
    44  	if specificReturn {
    45  		return ret.result1, ret.result2
    46  	}
    47  	fakeReturns := fake.parseReturns
    48  	return fakeReturns.result1, fakeReturns.result2
    49  }
    50  
    51  func (fake *PackageParser) ParseCallCount() int {
    52  	fake.parseMutex.RLock()
    53  	defer fake.parseMutex.RUnlock()
    54  	return len(fake.parseArgsForCall)
    55  }
    56  
    57  func (fake *PackageParser) ParseCalls(stub func([]byte) (*persistence.ChaincodePackage, error)) {
    58  	fake.parseMutex.Lock()
    59  	defer fake.parseMutex.Unlock()
    60  	fake.ParseStub = stub
    61  }
    62  
    63  func (fake *PackageParser) ParseArgsForCall(i int) []byte {
    64  	fake.parseMutex.RLock()
    65  	defer fake.parseMutex.RUnlock()
    66  	argsForCall := fake.parseArgsForCall[i]
    67  	return argsForCall.arg1
    68  }
    69  
    70  func (fake *PackageParser) ParseReturns(result1 *persistence.ChaincodePackage, result2 error) {
    71  	fake.parseMutex.Lock()
    72  	defer fake.parseMutex.Unlock()
    73  	fake.ParseStub = nil
    74  	fake.parseReturns = struct {
    75  		result1 *persistence.ChaincodePackage
    76  		result2 error
    77  	}{result1, result2}
    78  }
    79  
    80  func (fake *PackageParser) ParseReturnsOnCall(i int, result1 *persistence.ChaincodePackage, result2 error) {
    81  	fake.parseMutex.Lock()
    82  	defer fake.parseMutex.Unlock()
    83  	fake.ParseStub = nil
    84  	if fake.parseReturnsOnCall == nil {
    85  		fake.parseReturnsOnCall = make(map[int]struct {
    86  			result1 *persistence.ChaincodePackage
    87  			result2 error
    88  		})
    89  	}
    90  	fake.parseReturnsOnCall[i] = struct {
    91  		result1 *persistence.ChaincodePackage
    92  		result2 error
    93  	}{result1, result2}
    94  }
    95  
    96  func (fake *PackageParser) Invocations() map[string][][]interface{} {
    97  	fake.invocationsMutex.RLock()
    98  	defer fake.invocationsMutex.RUnlock()
    99  	fake.parseMutex.RLock()
   100  	defer fake.parseMutex.RUnlock()
   101  	copiedInvocations := map[string][][]interface{}{}
   102  	for key, value := range fake.invocations {
   103  		copiedInvocations[key] = value
   104  	}
   105  	return copiedInvocations
   106  }
   107  
   108  func (fake *PackageParser) recordInvocation(key string, args []interface{}) {
   109  	fake.invocationsMutex.Lock()
   110  	defer fake.invocationsMutex.Unlock()
   111  	if fake.invocations == nil {
   112  		fake.invocations = map[string][][]interface{}{}
   113  	}
   114  	if fake.invocations[key] == nil {
   115  		fake.invocations[key] = [][]interface{}{}
   116  	}
   117  	fake.invocations[key] = append(fake.invocations[key], args)
   118  }