-
Notifications
You must be signed in to change notification settings - Fork 202
/
workflow_test.go
41 lines (30 loc) · 1015 Bytes
/
workflow_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
package fileprocessing
import (
"testing"
"github.com/stretchr/testify/mock"
"go.temporal.io/sdk/worker"
"github.com/stretchr/testify/suite"
"go.temporal.io/sdk/testsuite"
)
type UnitTestSuite struct {
suite.Suite
testsuite.WorkflowTestSuite
}
func TestUnitTestSuite(t *testing.T) {
suite.Run(t, new(UnitTestSuite))
}
func (s *UnitTestSuite) Test_SampleFileProcessingWorkflow() {
env := s.NewTestWorkflowEnvironment()
env.SetWorkerOptions(worker.Options{
EnableSessionWorker: true, // Important for a worker to participate in the session
})
var a *Activities
env.OnActivity(a.DownloadFileActivity, mock.Anything, "file1").Return("file2", nil)
env.OnActivity(a.ProcessFileActivity, mock.Anything, "file2").Return("file3", nil)
env.OnActivity(a.UploadFileActivity, mock.Anything, "file3").Return(nil)
env.RegisterActivity(a)
env.ExecuteWorkflow(SampleFileProcessingWorkflow, "file1")
s.True(env.IsWorkflowCompleted())
s.NoError(env.GetWorkflowError())
env.AssertExpectations(s.T())
}