-
Notifications
You must be signed in to change notification settings - Fork 0
/
activity_test.go
50 lines (37 loc) · 1.05 KB
/
activity_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
package setevent
import (
"testing"
"github.com/project-flogo/core/activity"
"github.com/project-flogo/core/data/mapper"
"github.com/project-flogo/core/data/resolve"
"github.com/project-flogo/core/support/test"
"github.com/stretchr/testify/assert"
)
func TestRegister(t *testing.T) {
ref := activity.GetRef(&Activity{})
act := activity.Get(ref)
assert.NotNil(t, act)
}
func TestCreate(t *testing.T) {
mf := mapper.NewFactory(resolve.GetBasicResolver())
iCtx := test.NewActivityInitContext(Settings{}, mf)
act, err := New(iCtx)
assert.Nil(t, err)
assert.NotNil(t, act, "activity should not be nil")
}
func TestEval(t *testing.T) {
defer func() {
if r := recover(); r != nil {
t.Failed()
t.Errorf("panic during execution: %v", r)
}
}()
mf := mapper.NewFactory(resolve.GetBasicResolver())
iCtx := test.NewActivityInitContext(Settings{}, mf)
act, err := New(iCtx)
assert.Nil(t, err)
tc := test.NewActivityContext(act.Metadata())
tc.SetInputObject(&Input{Name: "testEvt", Payload: "testPayload"})
act.Eval(tc)
//check result attr
}