@@ -11,6 +11,7 @@ import (
11
11
"github.com/cschleiden/go-workflows/diag"
12
12
"github.com/cschleiden/go-workflows/internal/core"
13
13
"github.com/cschleiden/go-workflows/internal/history"
14
+ "github.com/cschleiden/go-workflows/internal/payload"
14
15
"github.com/cschleiden/go-workflows/workflow"
15
16
"github.com/google/uuid"
16
17
"github.com/stretchr/testify/require"
@@ -29,7 +30,6 @@ func BackendTest(t *testing.T, setup func() TestBackend, teardown func(b TestBac
29
30
err := b .CreateWorkflowInstance (
30
31
ctx ,
31
32
core .NewWorkflowInstance (instanceID , uuid .NewString ()),
32
- nil ,
33
33
history .NewHistoryEvent (1 , time .Now (), history .EventType_WorkflowExecutionStarted , & history.ExecutionStartedAttributes {}),
34
34
)
35
35
require .NoError (t , err )
@@ -43,15 +43,13 @@ func BackendTest(t *testing.T, setup func() TestBackend, teardown func(b TestBac
43
43
44
44
err := b .CreateWorkflowInstance (ctx ,
45
45
core .NewWorkflowInstance (instanceID , executionID ),
46
- nil ,
47
46
history .NewHistoryEvent (1 , time .Now (), history .EventType_WorkflowExecutionStarted , & history.ExecutionStartedAttributes {}),
48
47
)
49
48
require .NoError (t , err )
50
49
51
50
err = b .CreateWorkflowInstance (
52
51
ctx ,
53
52
core .NewWorkflowInstance (instanceID , executionID ),
54
- nil ,
55
53
history .NewHistoryEvent (1 , time .Now (), history .EventType_WorkflowExecutionStarted , & history.ExecutionStartedAttributes {}),
56
54
)
57
55
require .Error (t , err )
@@ -70,8 +68,9 @@ func BackendTest(t *testing.T, setup func() TestBackend, teardown func(b TestBac
70
68
err := b .CreateWorkflowInstance (
71
69
ctx ,
72
70
wfi ,
73
- metadata ,
74
- history .NewHistoryEvent (1 , time .Now (), history .EventType_WorkflowExecutionStarted , & history.ExecutionStartedAttributes {}),
71
+ history .NewHistoryEvent (1 , time .Now (), history .EventType_WorkflowExecutionStarted , & history.ExecutionStartedAttributes {
72
+ Metadata : metadata ,
73
+ }),
75
74
)
76
75
require .NoError (t , err )
77
76
@@ -100,7 +99,7 @@ func BackendTest(t *testing.T, setup func() TestBackend, teardown func(b TestBac
100
99
f : func (t * testing.T , ctx context.Context , b backend.Backend ) {
101
100
wfi := core .NewWorkflowInstance (uuid .NewString (), uuid .NewString ())
102
101
err := b .CreateWorkflowInstance (
103
- ctx , wfi , nil , history .NewHistoryEvent (1 , time .Now (), history .EventType_WorkflowExecutionStarted , & history.ExecutionStartedAttributes {}),
102
+ ctx , wfi , history .NewHistoryEvent (1 , time .Now (), history .EventType_WorkflowExecutionStarted , & history.ExecutionStartedAttributes {}),
104
103
)
105
104
require .NoError (t , err )
106
105
@@ -116,7 +115,7 @@ func BackendTest(t *testing.T, setup func() TestBackend, teardown func(b TestBac
116
115
f : func (t * testing.T , ctx context.Context , b backend.Backend ) {
117
116
wfi := core .NewWorkflowInstance (uuid .NewString (), uuid .NewString ())
118
117
err := b .CreateWorkflowInstance (
119
- ctx , wfi , nil , history .NewHistoryEvent (1 , time .Now (), history .EventType_WorkflowExecutionStarted , & history.ExecutionStartedAttributes {}),
118
+ ctx , wfi , history .NewHistoryEvent (1 , time .Now (), history .EventType_WorkflowExecutionStarted , & history.ExecutionStartedAttributes {}),
120
119
)
121
120
require .Nil (t , err )
122
121
@@ -138,7 +137,7 @@ func BackendTest(t *testing.T, setup func() TestBackend, teardown func(b TestBac
138
137
name : "CompleteWorkflowTask_ReturnsErrorIfNotLocked" ,
139
138
f : func (t * testing.T , ctx context.Context , b backend.Backend ) {
140
139
wfi := core .NewWorkflowInstance (uuid .NewString (), uuid .NewString ())
141
- err := b .CreateWorkflowInstance (ctx , wfi , nil , history .NewHistoryEvent (1 , time .Now (), history .EventType_WorkflowExecutionStarted , & history.ExecutionStartedAttributes {}))
140
+ err := b .CreateWorkflowInstance (ctx , wfi , history .NewHistoryEvent (1 , time .Now (), history .EventType_WorkflowExecutionStarted , & history.ExecutionStartedAttributes {}))
142
141
require .NoError (t , err )
143
142
144
143
tk , err := b .GetWorkflowTask (ctx )
@@ -161,7 +160,7 @@ func BackendTest(t *testing.T, setup func() TestBackend, teardown func(b TestBac
161
160
activityScheduledEvent := history .NewPendingEvent (time .Now (), history .EventType_ActivityScheduled , & history.ActivityScheduledAttributes {}, history .ScheduleEventID (1 ))
162
161
163
162
wfi := core .NewWorkflowInstance (uuid .NewString (), uuid .NewString ())
164
- err := b .CreateWorkflowInstance (ctx , wfi , nil , startedEvent )
163
+ err := b .CreateWorkflowInstance (ctx , wfi , startedEvent )
165
164
require .NoError (t , err )
166
165
167
166
task , err := b .GetWorkflowTask (ctx )
@@ -204,10 +203,14 @@ func BackendTest(t *testing.T, setup func() TestBackend, teardown func(b TestBac
204
203
{
205
204
name : "CompleteWorkflowTask_SetsCompletedAtWhenFinished" ,
206
205
f : func (t * testing.T , ctx context.Context , b backend.Backend ) {
207
- startedEvent := history .NewHistoryEvent (1 , time .Now (), history .EventType_WorkflowExecutionStarted , & history.ExecutionStartedAttributes {})
206
+ startedEvent := history .NewHistoryEvent (1 , time .Now (), history .EventType_WorkflowExecutionStarted , & history.ExecutionStartedAttributes {
207
+ Name : "some-workflow" ,
208
+ Inputs : []payload.Payload {},
209
+ Metadata : & core.WorkflowMetadata {},
210
+ })
208
211
209
212
wfi := core .NewWorkflowInstance (uuid .NewString (), uuid .NewString ())
210
- err := b .CreateWorkflowInstance (ctx , wfi , nil , startedEvent )
213
+ err := b .CreateWorkflowInstance (ctx , wfi , startedEvent )
211
214
require .NoError (t , err )
212
215
213
216
task , err := b .GetWorkflowTask (ctx )
@@ -281,7 +284,7 @@ func BackendTest(t *testing.T, setup func() TestBackend, teardown func(b TestBac
281
284
startWorkflow (t , ctx , b , c , subInstance1 )
282
285
283
286
// Create parent instance
284
- err := b .CreateWorkflowInstance (ctx , instance , nil , history .NewHistoryEvent (1 , time .Now (), history .EventType_WorkflowExecutionStarted , & history.ExecutionStartedAttributes {}))
287
+ err := b .CreateWorkflowInstance (ctx , instance , history .NewHistoryEvent (1 , time .Now (), history .EventType_WorkflowExecutionStarted , & history.ExecutionStartedAttributes {}))
285
288
require .NoError (t , err )
286
289
287
290
// Simulate context and sub-workflow cancellation
@@ -332,13 +335,15 @@ func BackendTest(t *testing.T, setup func() TestBackend, teardown func(b TestBac
332
335
}
333
336
334
337
func startWorkflow (t * testing.T , ctx context.Context , b backend.Backend , c client.Client , instance * core.WorkflowInstance ) {
335
- err := b .CreateWorkflowInstance (ctx , instance , nil , history .NewHistoryEvent (1 , time .Now (), history .EventType_WorkflowExecutionStarted , & history.ExecutionStartedAttributes {}))
338
+ err := b .CreateWorkflowInstance (
339
+ ctx , instance , history .NewHistoryEvent (1 , time .Now (), history .EventType_WorkflowExecutionStarted , & history.ExecutionStartedAttributes {}))
336
340
require .NoError (t , err )
337
341
338
342
// Get task to clear initial event
339
343
task , err := b .GetWorkflowTask (ctx )
340
344
require .NoError (t , err )
341
345
342
- err = b .CompleteWorkflowTask (ctx , task , instance , backend .WorkflowStateActive , task .NewEvents , []history.Event {}, []history.Event {}, []history.WorkflowEvent {})
346
+ err = b .CompleteWorkflowTask (
347
+ ctx , task , instance , backend .WorkflowStateActive , task .NewEvents , []history.Event {}, []history.Event {}, []history.WorkflowEvent {})
343
348
require .NoError (t , err )
344
349
}
0 commit comments