github.com/chenbh/concourse/v6@v6.4.2/tracing/tracingfakes/fake_tracer.go (about)

     1  // Code generated by counterfeiter. DO NOT EDIT.
     2  package tracingfakes
     3  
     4  import (
     5  	"context"
     6  	"sync"
     7  
     8  	"go.opentelemetry.io/otel/api/trace"
     9  )
    10  
    11  type FakeTracer struct {
    12  	StartStub        func(context.Context, string, ...trace.StartOption) (context.Context, trace.Span)
    13  	startMutex       sync.RWMutex
    14  	startArgsForCall []struct {
    15  		arg1 context.Context
    16  		arg2 string
    17  		arg3 []trace.StartOption
    18  	}
    19  	startReturns struct {
    20  		result1 context.Context
    21  		result2 trace.Span
    22  	}
    23  	startReturnsOnCall map[int]struct {
    24  		result1 context.Context
    25  		result2 trace.Span
    26  	}
    27  	WithSpanStub        func(context.Context, string, func(ctx context.Context) error) error
    28  	withSpanMutex       sync.RWMutex
    29  	withSpanArgsForCall []struct {
    30  		arg1 context.Context
    31  		arg2 string
    32  		arg3 func(ctx context.Context) error
    33  	}
    34  	withSpanReturns struct {
    35  		result1 error
    36  	}
    37  	withSpanReturnsOnCall map[int]struct {
    38  		result1 error
    39  	}
    40  	invocations      map[string][][]interface{}
    41  	invocationsMutex sync.RWMutex
    42  }
    43  
    44  func (fake *FakeTracer) Start(arg1 context.Context, arg2 string, arg3 ...trace.StartOption) (context.Context, trace.Span) {
    45  	fake.startMutex.Lock()
    46  	ret, specificReturn := fake.startReturnsOnCall[len(fake.startArgsForCall)]
    47  	fake.startArgsForCall = append(fake.startArgsForCall, struct {
    48  		arg1 context.Context
    49  		arg2 string
    50  		arg3 []trace.StartOption
    51  	}{arg1, arg2, arg3})
    52  	fake.recordInvocation("Start", []interface{}{arg1, arg2, arg3})
    53  	fake.startMutex.Unlock()
    54  	if fake.StartStub != nil {
    55  		return fake.StartStub(arg1, arg2, arg3...)
    56  	}
    57  	if specificReturn {
    58  		return ret.result1, ret.result2
    59  	}
    60  	fakeReturns := fake.startReturns
    61  	return fakeReturns.result1, fakeReturns.result2
    62  }
    63  
    64  func (fake *FakeTracer) StartCallCount() int {
    65  	fake.startMutex.RLock()
    66  	defer fake.startMutex.RUnlock()
    67  	return len(fake.startArgsForCall)
    68  }
    69  
    70  func (fake *FakeTracer) StartCalls(stub func(context.Context, string, ...trace.StartOption) (context.Context, trace.Span)) {
    71  	fake.startMutex.Lock()
    72  	defer fake.startMutex.Unlock()
    73  	fake.StartStub = stub
    74  }
    75  
    76  func (fake *FakeTracer) StartArgsForCall(i int) (context.Context, string, []trace.StartOption) {
    77  	fake.startMutex.RLock()
    78  	defer fake.startMutex.RUnlock()
    79  	argsForCall := fake.startArgsForCall[i]
    80  	return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3
    81  }
    82  
    83  func (fake *FakeTracer) StartReturns(result1 context.Context, result2 trace.Span) {
    84  	fake.startMutex.Lock()
    85  	defer fake.startMutex.Unlock()
    86  	fake.StartStub = nil
    87  	fake.startReturns = struct {
    88  		result1 context.Context
    89  		result2 trace.Span
    90  	}{result1, result2}
    91  }
    92  
    93  func (fake *FakeTracer) StartReturnsOnCall(i int, result1 context.Context, result2 trace.Span) {
    94  	fake.startMutex.Lock()
    95  	defer fake.startMutex.Unlock()
    96  	fake.StartStub = nil
    97  	if fake.startReturnsOnCall == nil {
    98  		fake.startReturnsOnCall = make(map[int]struct {
    99  			result1 context.Context
   100  			result2 trace.Span
   101  		})
   102  	}
   103  	fake.startReturnsOnCall[i] = struct {
   104  		result1 context.Context
   105  		result2 trace.Span
   106  	}{result1, result2}
   107  }
   108  
   109  func (fake *FakeTracer) WithSpan(arg1 context.Context, arg2 string, arg3 func(ctx context.Context) error) error {
   110  	fake.withSpanMutex.Lock()
   111  	ret, specificReturn := fake.withSpanReturnsOnCall[len(fake.withSpanArgsForCall)]
   112  	fake.withSpanArgsForCall = append(fake.withSpanArgsForCall, struct {
   113  		arg1 context.Context
   114  		arg2 string
   115  		arg3 func(ctx context.Context) error
   116  	}{arg1, arg2, arg3})
   117  	fake.recordInvocation("WithSpan", []interface{}{arg1, arg2, arg3})
   118  	fake.withSpanMutex.Unlock()
   119  	if fake.WithSpanStub != nil {
   120  		return fake.WithSpanStub(arg1, arg2, arg3)
   121  	}
   122  	if specificReturn {
   123  		return ret.result1
   124  	}
   125  	fakeReturns := fake.withSpanReturns
   126  	return fakeReturns.result1
   127  }
   128  
   129  func (fake *FakeTracer) WithSpanCallCount() int {
   130  	fake.withSpanMutex.RLock()
   131  	defer fake.withSpanMutex.RUnlock()
   132  	return len(fake.withSpanArgsForCall)
   133  }
   134  
   135  func (fake *FakeTracer) WithSpanCalls(stub func(context.Context, string, func(ctx context.Context) error) error) {
   136  	fake.withSpanMutex.Lock()
   137  	defer fake.withSpanMutex.Unlock()
   138  	fake.WithSpanStub = stub
   139  }
   140  
   141  func (fake *FakeTracer) WithSpanArgsForCall(i int) (context.Context, string, func(ctx context.Context) error) {
   142  	fake.withSpanMutex.RLock()
   143  	defer fake.withSpanMutex.RUnlock()
   144  	argsForCall := fake.withSpanArgsForCall[i]
   145  	return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3
   146  }
   147  
   148  func (fake *FakeTracer) WithSpanReturns(result1 error) {
   149  	fake.withSpanMutex.Lock()
   150  	defer fake.withSpanMutex.Unlock()
   151  	fake.WithSpanStub = nil
   152  	fake.withSpanReturns = struct {
   153  		result1 error
   154  	}{result1}
   155  }
   156  
   157  func (fake *FakeTracer) WithSpanReturnsOnCall(i int, result1 error) {
   158  	fake.withSpanMutex.Lock()
   159  	defer fake.withSpanMutex.Unlock()
   160  	fake.WithSpanStub = nil
   161  	if fake.withSpanReturnsOnCall == nil {
   162  		fake.withSpanReturnsOnCall = make(map[int]struct {
   163  			result1 error
   164  		})
   165  	}
   166  	fake.withSpanReturnsOnCall[i] = struct {
   167  		result1 error
   168  	}{result1}
   169  }
   170  
   171  func (fake *FakeTracer) Invocations() map[string][][]interface{} {
   172  	fake.invocationsMutex.RLock()
   173  	defer fake.invocationsMutex.RUnlock()
   174  	fake.startMutex.RLock()
   175  	defer fake.startMutex.RUnlock()
   176  	fake.withSpanMutex.RLock()
   177  	defer fake.withSpanMutex.RUnlock()
   178  	copiedInvocations := map[string][][]interface{}{}
   179  	for key, value := range fake.invocations {
   180  		copiedInvocations[key] = value
   181  	}
   182  	return copiedInvocations
   183  }
   184  
   185  func (fake *FakeTracer) recordInvocation(key string, args []interface{}) {
   186  	fake.invocationsMutex.Lock()
   187  	defer fake.invocationsMutex.Unlock()
   188  	if fake.invocations == nil {
   189  		fake.invocations = map[string][][]interface{}{}
   190  	}
   191  	if fake.invocations[key] == nil {
   192  		fake.invocations[key] = [][]interface{}{}
   193  	}
   194  	fake.invocations[key] = append(fake.invocations[key], args)
   195  }
   196  
   197  var _ trace.Tracer = new(FakeTracer)