-
Notifications
You must be signed in to change notification settings - Fork 106
/
outputstdout_test.go
46 lines (38 loc) · 1.01 KB
/
outputstdout_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
package outputstdout
import (
"context"
"strings"
"testing"
"time"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tsaikd/gogstash/config"
"github.com/tsaikd/gogstash/config/goglog"
"github.com/tsaikd/gogstash/config/logevent"
)
func init() {
goglog.Logger.SetLevel(logrus.DebugLevel)
config.RegistOutputHandler(ModuleName, InitHandler)
}
func Test_output_stdout_module(t *testing.T) {
assert := assert.New(t)
assert.NotNil(assert)
require := require.New(t)
require.NotNil(require)
ctx := context.Background()
conf, err := config.LoadFromYAML([]byte(strings.TrimSpace(`
debugch: true
output:
- type: stdout
`)))
require.NoError(err)
require.NoError(conf.Start(ctx))
conf.TestInputEvent(logevent.LogEvent{
Timestamp: time.Now(),
Message: "outputstdout test message",
})
if event, err := conf.TestGetOutputEvent(300 * time.Millisecond); assert.NoError(err) {
require.Equal("outputstdout test message", event.Message)
}
}