-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathtrigger_test.go
54 lines (42 loc) · 1012 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
53
54
package coap
import (
"encoding/json"
"testing"
"github.com/project-flogo/core/action"
"github.com/project-flogo/core/support"
"github.com/project-flogo/core/support/test"
"github.com/project-flogo/core/trigger"
"github.com/stretchr/testify/assert"
)
func TestTrigger_Register(t *testing.T) {
ref := support.GetRef(&Trigger{})
f := trigger.GetFactory(ref)
assert.NotNil(t, f)
}
const testConfig string = `{
"id": "trigger-coap",
"ref": "github.com/project-flogo/device-contrib/trigger/coap",
"handlers": [
{
"settings": {
"path": "/flogo"
},
"action" : {
"id": "dummy"
}
}
]
}`
func TestRestTrigger_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() {
})}
trg, err := test.InitTrigger(f, config, actions)
assert.Nil(t, err)
assert.NotNil(t, trg)
err = trg.Start()
assert.Nil(t, err)
}