-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatbinder_test.go
More file actions
41 lines (31 loc) · 961 Bytes
/
statbinder_test.go
File metadata and controls
41 lines (31 loc) · 961 Bytes
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
package stats
import (
"context"
"testing"
"github.com/asecurityteam/messageprocessor"
"github.com/aws/aws-sdk-go/service/kinesis"
"github.com/golang/mock/gomock"
"github.com/rs/xstats"
"github.com/stretchr/testify/assert"
)
type dummyMessageProcessor struct {
testFunc func(ctx context.Context)
}
func (t *dummyMessageProcessor) ProcessMessage(ctx context.Context, record *kinesis.Record) messageprocessor.MessageProcessorError {
return nil
}
func TestStatBinder_ProcessMessage(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockStater := NewMockStat(ctrl)
processMessageFunc := func(ctx context.Context) {
stater := xstats.FromContext(ctx)
assert.Equal(t, mockStater, stater)
}
statBinder := NewStatBinder(mockStater)
messageProcessor := statBinder(&dummyMessageProcessor{
testFunc: processMessageFunc,
})
e := messageProcessor.ProcessMessage(context.Background(), &kinesis.Record{})
assert.Nil(t, e)
}