forked from vmware-archive/atc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
fake_emitter.go
71 lines (62 loc) · 1.84 KB
/
fake_emitter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Code generated by counterfeiter. DO NOT EDIT.
package metricfakes
import (
"sync"
"code.cloudfoundry.org/lager"
"github.com/concourse/atc/metric"
)
type FakeEmitter struct {
EmitStub func(lager.Logger, metric.Event)
emitMutex sync.RWMutex
emitArgsForCall []struct {
arg1 lager.Logger
arg2 metric.Event
}
invocations map[string][][]interface{}
invocationsMutex sync.RWMutex
}
func (fake *FakeEmitter) Emit(arg1 lager.Logger, arg2 metric.Event) {
fake.emitMutex.Lock()
fake.emitArgsForCall = append(fake.emitArgsForCall, struct {
arg1 lager.Logger
arg2 metric.Event
}{arg1, arg2})
fake.recordInvocation("Emit", []interface{}{arg1, arg2})
fake.emitMutex.Unlock()
if fake.EmitStub != nil {
fake.EmitStub(arg1, arg2)
}
}
func (fake *FakeEmitter) EmitCallCount() int {
fake.emitMutex.RLock()
defer fake.emitMutex.RUnlock()
return len(fake.emitArgsForCall)
}
func (fake *FakeEmitter) EmitArgsForCall(i int) (lager.Logger, metric.Event) {
fake.emitMutex.RLock()
defer fake.emitMutex.RUnlock()
return fake.emitArgsForCall[i].arg1, fake.emitArgsForCall[i].arg2
}
func (fake *FakeEmitter) Invocations() map[string][][]interface{} {
fake.invocationsMutex.RLock()
defer fake.invocationsMutex.RUnlock()
fake.emitMutex.RLock()
defer fake.emitMutex.RUnlock()
copiedInvocations := map[string][][]interface{}{}
for key, value := range fake.invocations {
copiedInvocations[key] = value
}
return copiedInvocations
}
func (fake *FakeEmitter) recordInvocation(key string, args []interface{}) {
fake.invocationsMutex.Lock()
defer fake.invocationsMutex.Unlock()
if fake.invocations == nil {
fake.invocations = map[string][][]interface{}{}
}
if fake.invocations[key] == nil {
fake.invocations[key] = [][]interface{}{}
}
fake.invocations[key] = append(fake.invocations[key], args)
}
var _ metric.Emitter = new(FakeEmitter)