github.com/yimialmonte/fabric@v2.1.1+incompatible/common/grpclogging/fakes/leveler.go (about)

     1  // Code generated by counterfeiter. DO NOT EDIT.
     2  package fakes
     3  
     4  import (
     5  	"context"
     6  	"sync"
     7  
     8  	"github.com/hyperledger/fabric/common/grpclogging"
     9  	"go.uber.org/zap/zapcore"
    10  )
    11  
    12  type Leveler struct {
    13  	Stub        func(context.Context, string) zapcore.Level
    14  	mutex       sync.RWMutex
    15  	argsForCall []struct {
    16  		arg1 context.Context
    17  		arg2 string
    18  	}
    19  	returns struct {
    20  		result1 zapcore.Level
    21  	}
    22  	returnsOnCall map[int]struct {
    23  		result1 zapcore.Level
    24  	}
    25  	invocations      map[string][][]interface{}
    26  	invocationsMutex sync.RWMutex
    27  }
    28  
    29  func (fake *Leveler) Spy(arg1 context.Context, arg2 string) zapcore.Level {
    30  	fake.mutex.Lock()
    31  	ret, specificReturn := fake.returnsOnCall[len(fake.argsForCall)]
    32  	fake.argsForCall = append(fake.argsForCall, struct {
    33  		arg1 context.Context
    34  		arg2 string
    35  	}{arg1, arg2})
    36  	fake.recordInvocation("LevelerFunc", []interface{}{arg1, arg2})
    37  	fake.mutex.Unlock()
    38  	if fake.Stub != nil {
    39  		return fake.Stub(arg1, arg2)
    40  	}
    41  	if specificReturn {
    42  		return ret.result1
    43  	}
    44  	return fake.returns.result1
    45  }
    46  
    47  func (fake *Leveler) CallCount() int {
    48  	fake.mutex.RLock()
    49  	defer fake.mutex.RUnlock()
    50  	return len(fake.argsForCall)
    51  }
    52  
    53  func (fake *Leveler) Calls(stub func(context.Context, string) zapcore.Level) {
    54  	fake.mutex.Lock()
    55  	defer fake.mutex.Unlock()
    56  	fake.Stub = stub
    57  }
    58  
    59  func (fake *Leveler) ArgsForCall(i int) (context.Context, string) {
    60  	fake.mutex.RLock()
    61  	defer fake.mutex.RUnlock()
    62  	return fake.argsForCall[i].arg1, fake.argsForCall[i].arg2
    63  }
    64  
    65  func (fake *Leveler) Returns(result1 zapcore.Level) {
    66  	fake.mutex.Lock()
    67  	defer fake.mutex.Unlock()
    68  	fake.Stub = nil
    69  	fake.returns = struct {
    70  		result1 zapcore.Level
    71  	}{result1}
    72  }
    73  
    74  func (fake *Leveler) ReturnsOnCall(i int, result1 zapcore.Level) {
    75  	fake.mutex.Lock()
    76  	defer fake.mutex.Unlock()
    77  	fake.Stub = nil
    78  	if fake.returnsOnCall == nil {
    79  		fake.returnsOnCall = make(map[int]struct {
    80  			result1 zapcore.Level
    81  		})
    82  	}
    83  	fake.returnsOnCall[i] = struct {
    84  		result1 zapcore.Level
    85  	}{result1}
    86  }
    87  
    88  func (fake *Leveler) Invocations() map[string][][]interface{} {
    89  	fake.invocationsMutex.RLock()
    90  	defer fake.invocationsMutex.RUnlock()
    91  	fake.mutex.RLock()
    92  	defer fake.mutex.RUnlock()
    93  	copiedInvocations := map[string][][]interface{}{}
    94  	for key, value := range fake.invocations {
    95  		copiedInvocations[key] = value
    96  	}
    97  	return copiedInvocations
    98  }
    99  
   100  func (fake *Leveler) recordInvocation(key string, args []interface{}) {
   101  	fake.invocationsMutex.Lock()
   102  	defer fake.invocationsMutex.Unlock()
   103  	if fake.invocations == nil {
   104  		fake.invocations = map[string][][]interface{}{}
   105  	}
   106  	if fake.invocations[key] == nil {
   107  		fake.invocations[key] = [][]interface{}{}
   108  	}
   109  	fake.invocations[key] = append(fake.invocations[key], args)
   110  }
   111  
   112  var _ grpclogging.LevelerFunc = new(Leveler).Spy