-
Notifications
You must be signed in to change notification settings - Fork 1
/
trigger_test.go
64 lines (52 loc) · 1.32 KB
/
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
55
56
57
58
59
60
61
62
63
64
package amqp
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"
)
const testConfig string = `{
"id": "flogo-amqp",
"ref": "github.com/skothari-tibco/amqp-trigger",
"settings": {
"amqpURI": "amqp://zfdqtzvv:[email protected]/zfdqtzvv",
"consumerTag": "client1",
"certPem":"/Users/skothari-tibco/Desktop/cert.pem",
"keyPem":"/Users/skothari-tibco/Desktop/key.pem"
},
"handlers": [
{
"action":{
"id":"dummy"
},
"settings": {
"queue": "hello",
"exchange": "test-excahnge",
"bindingKey" : "red",
"exchangeType":"direct"
}
}
]
}`
func TestTrigger_Register(t *testing.T) {
ref := support.GetRef(&AMQPTrigger{})
f := trigger.GetFactory(ref)
assert.NotNil(t, f)
}
func TestAMQPTrigger_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)
}