forked from project-flogo/contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
timer_test.go
56 lines (46 loc) · 1004 Bytes
/
timer_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
package timer
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/timer",
"handlers": [
{
"settings":{
"repeatInterval" : "1s"
},
"action":{
"id":"dummy"
}
}
]
}
`
func TestInitOk(t *testing.T) {
f := &Factory{}
tgr, err := f.New(nil)
assert.Nil(t, err)
assert.NotNil(t, tgr)
}
func TestTimerTrigger_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)
}