github.com/true-sqn/fabric@v2.1.1+incompatible/orderer/consensus/etcdraft/mocks/configurator.go (about)

     1  // Code generated by counterfeiter. DO NOT EDIT.
     2  package mocks
     3  
     4  import (
     5  	"sync"
     6  
     7  	"github.com/hyperledger/fabric/orderer/common/cluster"
     8  	"github.com/hyperledger/fabric/orderer/consensus/etcdraft"
     9  )
    10  
    11  type FakeConfigurator struct {
    12  	ConfigureStub        func(string, []cluster.RemoteNode)
    13  	configureMutex       sync.RWMutex
    14  	configureArgsForCall []struct {
    15  		arg1 string
    16  		arg2 []cluster.RemoteNode
    17  	}
    18  	invocations      map[string][][]interface{}
    19  	invocationsMutex sync.RWMutex
    20  }
    21  
    22  func (fake *FakeConfigurator) Configure(arg1 string, arg2 []cluster.RemoteNode) {
    23  	var arg2Copy []cluster.RemoteNode
    24  	if arg2 != nil {
    25  		arg2Copy = make([]cluster.RemoteNode, len(arg2))
    26  		copy(arg2Copy, arg2)
    27  	}
    28  	fake.configureMutex.Lock()
    29  	fake.configureArgsForCall = append(fake.configureArgsForCall, struct {
    30  		arg1 string
    31  		arg2 []cluster.RemoteNode
    32  	}{arg1, arg2Copy})
    33  	fake.recordInvocation("Configure", []interface{}{arg1, arg2Copy})
    34  	fake.configureMutex.Unlock()
    35  	if fake.ConfigureStub != nil {
    36  		fake.ConfigureStub(arg1, arg2)
    37  	}
    38  }
    39  
    40  func (fake *FakeConfigurator) ConfigureCallCount() int {
    41  	fake.configureMutex.RLock()
    42  	defer fake.configureMutex.RUnlock()
    43  	return len(fake.configureArgsForCall)
    44  }
    45  
    46  func (fake *FakeConfigurator) ConfigureCalls(stub func(string, []cluster.RemoteNode)) {
    47  	fake.configureMutex.Lock()
    48  	defer fake.configureMutex.Unlock()
    49  	fake.ConfigureStub = stub
    50  }
    51  
    52  func (fake *FakeConfigurator) ConfigureArgsForCall(i int) (string, []cluster.RemoteNode) {
    53  	fake.configureMutex.RLock()
    54  	defer fake.configureMutex.RUnlock()
    55  	argsForCall := fake.configureArgsForCall[i]
    56  	return argsForCall.arg1, argsForCall.arg2
    57  }
    58  
    59  func (fake *FakeConfigurator) Invocations() map[string][][]interface{} {
    60  	fake.invocationsMutex.RLock()
    61  	defer fake.invocationsMutex.RUnlock()
    62  	fake.configureMutex.RLock()
    63  	defer fake.configureMutex.RUnlock()
    64  	copiedInvocations := map[string][][]interface{}{}
    65  	for key, value := range fake.invocations {
    66  		copiedInvocations[key] = value
    67  	}
    68  	return copiedInvocations
    69  }
    70  
    71  func (fake *FakeConfigurator) recordInvocation(key string, args []interface{}) {
    72  	fake.invocationsMutex.Lock()
    73  	defer fake.invocationsMutex.Unlock()
    74  	if fake.invocations == nil {
    75  		fake.invocations = map[string][][]interface{}{}
    76  	}
    77  	if fake.invocations[key] == nil {
    78  		fake.invocations[key] = [][]interface{}{}
    79  	}
    80  	fake.invocations[key] = append(fake.invocations[key], args)
    81  }
    82  
    83  var _ etcdraft.Configurator = new(FakeConfigurator)