|
21 | 21 | package replaytests
|
22 | 22 |
|
23 | 23 | import (
|
| 24 | + "strings" |
24 | 25 | "testing"
|
25 | 26 |
|
26 |
| - "github.com/golang/mock/gomock" |
27 | 27 | "github.com/stretchr/testify/require"
|
28 |
| - "github.com/stretchr/testify/suite" |
29 |
| - "go.uber.org/cadence/.gen/go/cadence/workflowservicetest" |
30 | 28 | "go.uber.org/cadence/worker"
|
31 |
| - "go.uber.org/zap" |
| 29 | + "go.uber.org/zap/zaptest" |
32 | 30 | )
|
33 | 31 |
|
34 |
| -type replayTestSuite struct { |
35 |
| - suite.Suite |
36 |
| - mockCtrl *gomock.Controller |
37 |
| - service *workflowservicetest.MockClient |
38 |
| -} |
39 |
| - |
40 |
| -func TestReplayTestSuite(t *testing.T) { |
41 |
| - s := new(replayTestSuite) |
42 |
| - suite.Run(t, s) |
43 |
| -} |
44 |
| - |
45 |
| -func (s *replayTestSuite) SetupTest() { |
46 |
| - s.mockCtrl = gomock.NewController(s.T()) |
47 |
| - s.service = workflowservicetest.NewMockClient(s.mockCtrl) |
48 |
| -} |
49 |
| - |
50 |
| -func (s *replayTestSuite) TearDownTest() { |
51 |
| - s.mockCtrl.Finish() // assert mock’s expectations |
52 |
| -} |
53 |
| - |
54 |
| -func (s *replayTestSuite) TestReplayWorkflowHistoryFromFile() { |
55 |
| - logger, _ := zap.NewDevelopment() |
56 |
| - testFiles := []string{"basic.json", "basic_new.json", "version.json", "version_new.json"} |
57 |
| - var err error |
58 |
| - |
59 |
| - for _, testFile := range testFiles { |
60 |
| - replayer := worker.NewWorkflowReplayer() |
61 |
| - replayer.RegisterWorkflow(Workflow) |
62 |
| - replayer.RegisterWorkflow(Workflow2) |
| 32 | +func TestReplayWorkflowHistoryFromFile(t *testing.T) { |
| 33 | + for _, testFile := range []string{"basic.json", "basic_new.json", "version.json", "version_new.json"} { |
| 34 | + t.Run("replay_"+strings.Split(testFile, ".")[0], func(t *testing.T) { |
| 35 | + replayer := worker.NewWorkflowReplayer() |
| 36 | + replayer.RegisterWorkflow(Workflow) |
| 37 | + replayer.RegisterWorkflow(Workflow2) |
63 | 38 |
|
64 |
| - err = replayer.ReplayWorkflowHistoryFromJSONFile(logger, testFile) |
65 |
| - require.NoError(s.T(), err) |
| 39 | + err := replayer.ReplayWorkflowHistoryFromJSONFile(zaptest.NewLogger(t), testFile) |
| 40 | + require.NoError(t, err) |
| 41 | + }) |
66 | 42 | }
|
67 | 43 | }
|
0 commit comments