-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathactivity_test.go
50 lines (41 loc) · 1.15 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 mongodb
import (
"fmt"
"testing"
"github.com/project-flogo/core/activity"
"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 TestInsert(t *testing.T) {
settings := &Settings{URI: "localhost:27017"}
iCtx := test.NewActivityInitContext(settings, nil)
act, err := New(iCtx)
assert.Nil(t, err)
tc := test.NewActivityContext(act.Metadata())
tc.SetInput("method", "GET")
tc.SetInput("collection", "numbers")
tc.SetInput("dbname", "numbers2")
act.Eval(tc)
}
func TestUpdate(t *testing.T) {
settings := &Settings{URI: "localhost:27017"}
iCtx := test.NewActivityInitContext(settings, nil)
act, err := New(iCtx)
assert.Nil(t, err)
data := map[string]interface{}{"foo": "bar23"}
tc := test.NewActivityContext(act.Metadata())
tc.SetInput("method", "UPDATE")
tc.SetInput("collection", "numbers")
tc.SetInput("dbname", "numbers")
tc.SetInput("keyname", "foo")
tc.SetInput("keyvalue", "bar")
tc.SetInput("data", data)
res, err := act.Eval(tc)
assert.Nil(t, err)
fmt.Println("Res", res)
}