-
Notifications
You must be signed in to change notification settings - Fork 33
/
action_test.go
64 lines (53 loc) · 1.26 KB
/
action_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 stream
import (
"encoding/json"
"testing"
"github.com/project-flogo/core/action"
"github.com/project-flogo/core/app/resource"
"github.com/project-flogo/core/engine/channels"
"github.com/project-flogo/core/support/test"
"github.com/project-flogo/stream/pipeline"
"github.com/stretchr/testify/assert"
)
const testConfig string = `{
"id": "flogo-stream",
"ref": "github.com/project-flogo/stream",
"settings": {
"streamURI": "res://stream:test",
"outputChannel": "testChan"
}
}
`
const resData string = `{
"metadata": {
"input": [
{
"name": "input",
"type": "integer"
}
]
},
"stages": [
]
}`
func TestActionFactory_New(t *testing.T) {
cfg := &action.Config{}
err := json.Unmarshal([]byte(testConfig), cfg)
if err != nil {
t.Error(err)
return
}
af := ActionFactory{}
ctx := test.NewActionInitCtx()
err = af.Initialize(ctx)
assert.Nil(t, err)
resourceCfg := &resource.Config{ID: "stream:test"}
resourceCfg.Data = []byte(resData)
err = ctx.AddResource(pipeline.ResType, resourceCfg)
assert.Nil(t, err)
_, err = channels.New("testChan", 5)
assert.Nil(t, err)
act, err := af.New(cfg)
assert.Nil(t, err)
assert.NotNil(t, act)
}