forked from inthecloud247/heka-clever-plugins
/
mock_filter_runner_test.go
103 lines (83 loc) · 2.53 KB
/
mock_filter_runner_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
92
93
94
95
96
97
98
99
100
101
102
103
package heka_clever_plugins
import (
"github.com/mozilla-services/heka/pipeline"
"github.com/mozilla-services/heka/pipelinemock"
"github.com/rafrombrc/gomock/gomock"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"sync"
"time"
)
// MockFilterRunner
type MockFilterRunner struct {
mock mock.Mock
t mock.TestingT
}
func (mfr *MockFilterRunner) EXPECT() *mock.Mock {
return &mfr.mock
}
func (mfr *MockFilterRunner) ExpectCall(description string, method string, predicate func([]interface{}) bool) {
foundMatchingCall := false
for _, call := range mfr.mock.Calls {
if call.Method == method && predicate(call.Arguments) {
foundMatchingCall = true
break
}
}
assert.True(mfr.t, foundMatchingCall, "No matching call found for call '%s'", description)
}
func (mfr *MockFilterRunner) InChan() chan *pipeline.PipelinePack {
args := mfr.mock.Called()
return args.Get(0).(chan *pipeline.PipelinePack)
}
func (mfr *MockFilterRunner) Filter() pipeline.Filter {
panic("Method not implemented")
}
func (mfr *MockFilterRunner) Start(h pipeline.PluginHelper, wg *sync.WaitGroup) error {
panic("Method not implemented")
}
func (mfr *MockFilterRunner) Ticker() (ticker <-chan time.Time) {
panic("Method not implemented")
}
func (mfr *MockFilterRunner) Inject(pack *pipeline.PipelinePack) bool {
args := mfr.mock.Called(pack)
return args.Bool(0)
}
func (mfr *MockFilterRunner) MatchRunner() *pipeline.MatchRunner {
panic("Method not implemented")
}
func (mfr *MockFilterRunner) RetainPack(pack *pipeline.PipelinePack) {
panic("Method not implemented")
}
func (mfr *MockFilterRunner) Name() string {
panic("Method not implemented")
}
func (mfr *MockFilterRunner) SetName(name string) {
panic("Method not implemented")
}
func (mfr *MockFilterRunner) Plugin() pipeline.Plugin {
panic("Method not implemented")
}
func (mfr *MockFilterRunner) LogError(err error) {
mfr.mock.Called(err)
}
func (mfr *MockFilterRunner) LogMessage(msg string) {
panic("Method not implemented")
}
func (mfr *MockFilterRunner) SetLeakCount(count int) {
panic("Method not implemented")
}
func (mfr *MockFilterRunner) LeakCount() int {
panic("Method not implemented")
}
// FilterTestHelper
type FilterTestHelper struct {
MockHelper *pipelinemock.MockPluginHelper
MockFilterRunner *MockFilterRunner
}
func NewFilterTestHelper(t mock.TestingT, ctrl *gomock.Controller) *FilterTestHelper {
fth := new(FilterTestHelper)
fth.MockHelper = pipelinemock.NewMockPluginHelper(ctrl)
fth.MockFilterRunner = &MockFilterRunner{mock.Mock{}, t}
return fth
}