-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathtrigger_test.go
52 lines (42 loc) · 939 Bytes
/
trigger_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
package kafka
import (
"encoding/json"
"testing"
"github.com/project-flogo/core/action"
"github.com/project-flogo/core/support/test"
"github.com/project-flogo/core/trigger"
"github.com/stretchr/testify/assert"
)
const testConfig string = `{
"id": "flogo-timer",
"ref": "github.com/project-flogo/contrib/trigger/kafka",
"settings": {
"brokerUrls": "localhost:9092"
},
"handlers": [
{
"action":{
"id":"dummy"
},
"settings": {
"topic": "syslog"
}
}
]
}`
func TestKafkaTrigger_Initialize(t *testing.T) {
f := &Factory{}
config := &trigger.Config{}
err := json.Unmarshal([]byte(testConfig), config)
assert.Nil(t, err)
actions := map[string]action.Action{"dummy": test.NewDummyAction(func() {
//do nothing
})}
trg, err := test.InitTrigger(f, config, actions)
assert.Nil(t, err)
assert.NotNil(t, trg)
err = trg.Start()
assert.Nil(t, err)
err = trg.Stop()
assert.Nil(t, err)
}