-
Notifications
You must be signed in to change notification settings - Fork 58
/
external-task_integration_test.go
71 lines (61 loc) · 1.67 KB
/
external-task_integration_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
65
66
67
68
69
70
71
//go:build integration
// +build integration
package camunda_client_go
import (
"github.com/stretchr/testify/assert"
"testing"
"time"
)
func TestFetchAndLockIntegration(t *testing.T) {
processKey := "hello-world-process"
_, err := client.ProcessDefinition.StartInstance(
QueryProcessDefinitionBy{Key: &processKey},
ReqStartInstance{Variables: &map[string]Variable{
"isWorld": {Value: false, Type: "boolean"},
"test": {Value: false, Type: "boolean"},
}},
)
assert.NoError(t, err)
_, err = client.ProcessDefinition.StartInstance(
QueryProcessDefinitionBy{Key: &processKey},
ReqStartInstance{Variables: &map[string]Variable{
"isWorld": {Value: false, Type: "boolean"},
"test": {Value: true, Type: "boolean"},
}},
)
assert.NoError(t, err)
// wait processing StartInstance in camunda
time.Sleep(time.Second * 15)
tasks, err := client.ExternalTask.FetchAndLock(QueryFetchAndLock{
WorkerId: "test-fetch-and-lock-integration",
MaxTasks: 10,
Topics: []*QueryFetchAndLockTopic{
{
LockDuration: 1000,
TopicName: "PrintHello",
ProcessVariables: map[string]interface{}{
"test": false,
},
},
},
})
assert.NoError(t, err)
assert.Len(t, tasks, 1)
assert.False(t, tasks[0].Variables["test"].Value.(bool))
tasks, err = client.ExternalTask.FetchAndLock(QueryFetchAndLock{
WorkerId: "test-fetch-and-lock-integration",
MaxTasks: 10,
Topics: []*QueryFetchAndLockTopic{
{
LockDuration: 1000,
TopicName: "PrintHello",
ProcessVariables: map[string]interface{}{
"test": true,
},
},
},
})
assert.NoError(t, err)
assert.Len(t, tasks, 1)
assert.True(t, tasks[0].Variables["test"].Value.(bool))
}