forked from xmidt-org/ancla
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmocks_test.go
91 lines (72 loc) · 1.96 KB
/
mocks_test.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package ancla
import (
"context"
"github.com/go-kit/kit/metrics"
"github.com/stretchr/testify/mock"
"github.com/xmidt-org/argus/chrysom"
"github.com/xmidt-org/argus/model"
)
type mockPushReader struct {
mock.Mock
}
func (m *mockPushReader) GetItems(ctx context.Context, owner string) (chrysom.Items, error) {
args := m.Called(ctx, owner)
return args.Get(0).(chrysom.Items), args.Error(1)
}
func (m *mockPushReader) Start(ctx context.Context) error {
args := m.Called(ctx)
return args.Error(0)
}
func (m *mockPushReader) Stop(ctx context.Context) error {
args := m.Called(ctx)
return args.Error(0)
}
func (m *mockPushReader) PushItem(ctx context.Context, owner string, item model.Item) (chrysom.PushResult, error) {
args := m.Called(ctx, owner, item)
return args.Get(0).(chrysom.PushResult), args.Error(1)
}
func (m *mockPushReader) RemoveItem(ctx context.Context, id, owner string) (model.Item, error) {
args := m.Called(ctx, id, owner)
return args.Get(0).(model.Item), args.Error(0)
}
type mockService struct {
mock.Mock
}
func (m *mockService) Add(ctx context.Context, owner string, w Webhook) error {
args := m.Called(ctx, owner, w)
return args.Error(0)
}
func (m *mockService) AllWebhooks(ctx context.Context) ([]Webhook, error) {
args := m.Called(ctx)
return args.Get(0).([]Webhook), args.Error(1)
}
type mockCounter struct {
mock.Mock
}
func (m *mockCounter) With(labelValues ...string) metrics.Counter {
m.Called(interfacify(labelValues)...)
return m
}
func (m *mockCounter) Add(delta float64) {
m.Called(delta)
}
type mockGauge struct {
mock.Mock
}
func (m *mockGauge) With(labelValues ...string) metrics.Gauge {
m.Called(interfacify(labelValues)...)
return m
}
func (m *mockGauge) Set(value float64) {
m.Called(value)
}
func (m *mockGauge) Add(delta float64) {
m.Called(delta)
}
func interfacify(vals []string) []interface{} {
transformed := make([]interface{}, len(vals))
for i, val := range vals {
transformed[i] = val
}
return transformed
}