github.com/ahlemtn/fabric@v2.1.1+incompatible/core/container/mock/external_builder.go (about)

     1  // Code generated by counterfeiter. DO NOT EDIT.
     2  package mock
     3  
     4  import (
     5  	"io"
     6  	"sync"
     7  
     8  	"github.com/hyperledger/fabric/core/container"
     9  )
    10  
    11  type ExternalBuilder struct {
    12  	BuildStub        func(string, []byte, io.Reader) (container.Instance, error)
    13  	buildMutex       sync.RWMutex
    14  	buildArgsForCall []struct {
    15  		arg1 string
    16  		arg2 []byte
    17  		arg3 io.Reader
    18  	}
    19  	buildReturns struct {
    20  		result1 container.Instance
    21  		result2 error
    22  	}
    23  	buildReturnsOnCall map[int]struct {
    24  		result1 container.Instance
    25  		result2 error
    26  	}
    27  	invocations      map[string][][]interface{}
    28  	invocationsMutex sync.RWMutex
    29  }
    30  
    31  func (fake *ExternalBuilder) Build(arg1 string, arg2 []byte, arg3 io.Reader) (container.Instance, error) {
    32  	var arg2Copy []byte
    33  	if arg2 != nil {
    34  		arg2Copy = make([]byte, len(arg2))
    35  		copy(arg2Copy, arg2)
    36  	}
    37  	fake.buildMutex.Lock()
    38  	ret, specificReturn := fake.buildReturnsOnCall[len(fake.buildArgsForCall)]
    39  	fake.buildArgsForCall = append(fake.buildArgsForCall, struct {
    40  		arg1 string
    41  		arg2 []byte
    42  		arg3 io.Reader
    43  	}{arg1, arg2Copy, arg3})
    44  	fake.recordInvocation("Build", []interface{}{arg1, arg2Copy, arg3})
    45  	fake.buildMutex.Unlock()
    46  	if fake.BuildStub != nil {
    47  		return fake.BuildStub(arg1, arg2, arg3)
    48  	}
    49  	if specificReturn {
    50  		return ret.result1, ret.result2
    51  	}
    52  	fakeReturns := fake.buildReturns
    53  	return fakeReturns.result1, fakeReturns.result2
    54  }
    55  
    56  func (fake *ExternalBuilder) BuildCallCount() int {
    57  	fake.buildMutex.RLock()
    58  	defer fake.buildMutex.RUnlock()
    59  	return len(fake.buildArgsForCall)
    60  }
    61  
    62  func (fake *ExternalBuilder) BuildCalls(stub func(string, []byte, io.Reader) (container.Instance, error)) {
    63  	fake.buildMutex.Lock()
    64  	defer fake.buildMutex.Unlock()
    65  	fake.BuildStub = stub
    66  }
    67  
    68  func (fake *ExternalBuilder) BuildArgsForCall(i int) (string, []byte, io.Reader) {
    69  	fake.buildMutex.RLock()
    70  	defer fake.buildMutex.RUnlock()
    71  	argsForCall := fake.buildArgsForCall[i]
    72  	return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3
    73  }
    74  
    75  func (fake *ExternalBuilder) BuildReturns(result1 container.Instance, result2 error) {
    76  	fake.buildMutex.Lock()
    77  	defer fake.buildMutex.Unlock()
    78  	fake.BuildStub = nil
    79  	fake.buildReturns = struct {
    80  		result1 container.Instance
    81  		result2 error
    82  	}{result1, result2}
    83  }
    84  
    85  func (fake *ExternalBuilder) BuildReturnsOnCall(i int, result1 container.Instance, result2 error) {
    86  	fake.buildMutex.Lock()
    87  	defer fake.buildMutex.Unlock()
    88  	fake.BuildStub = nil
    89  	if fake.buildReturnsOnCall == nil {
    90  		fake.buildReturnsOnCall = make(map[int]struct {
    91  			result1 container.Instance
    92  			result2 error
    93  		})
    94  	}
    95  	fake.buildReturnsOnCall[i] = struct {
    96  		result1 container.Instance
    97  		result2 error
    98  	}{result1, result2}
    99  }
   100  
   101  func (fake *ExternalBuilder) Invocations() map[string][][]interface{} {
   102  	fake.invocationsMutex.RLock()
   103  	defer fake.invocationsMutex.RUnlock()
   104  	fake.buildMutex.RLock()
   105  	defer fake.buildMutex.RUnlock()
   106  	copiedInvocations := map[string][][]interface{}{}
   107  	for key, value := range fake.invocations {
   108  		copiedInvocations[key] = value
   109  	}
   110  	return copiedInvocations
   111  }
   112  
   113  func (fake *ExternalBuilder) recordInvocation(key string, args []interface{}) {
   114  	fake.invocationsMutex.Lock()
   115  	defer fake.invocationsMutex.Unlock()
   116  	if fake.invocations == nil {
   117  		fake.invocations = map[string][][]interface{}{}
   118  	}
   119  	if fake.invocations[key] == nil {
   120  		fake.invocations[key] = [][]interface{}{}
   121  	}
   122  	fake.invocations[key] = append(fake.invocations[key], args)
   123  }
   124  
   125  var _ container.ExternalBuilder = new(ExternalBuilder)