Skip to content

Commit 07e13c3

Browse files
arzonusGroxx
andauthored
Apply suggestions from code review
Co-authored-by: Steven L <[email protected]>
1 parent 974a846 commit 07e13c3

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

internal/internal_workflow_testsuite_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,10 +1414,8 @@ func (s *WorkflowTestSuiteUnitTest) Test_MockGetVersion_ExecuteWithVersion() {
14141414
env.RegisterActivity(oldActivity)
14151415
env.RegisterActivity(newActivity)
14161416

1417-
env.OnGetVersion("change_1", DefaultVersion, 2).Return(func(string, Version, Version) Version {
1418-
return DefaultVersion
1419-
})
1420-
env.OnGetVersion(mock.Anything, DefaultVersion, 2).Return(Version(2))
1417+
env.OnGetVersion("change_1", DefaultVersion, 2).Return(DefaultVersion)
1418+
env.OnGetVersion("change_2", DefaultVersion, 2).Return(Version(2))
14211419
env.ExecuteWorkflow(workflowFn)
14221420

14231421
s.True(env.IsWorkflowCompleted())

internal/workflow_testsuite.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,6 @@ func (t *TestWorkflowEnvironment) OnRequestCancelExternalWorkflow(domainName, wo
366366

367367
// OnGetVersion setup a mock for workflow.GetVersion() call. By default, if mock is not setup, the GetVersion call from
368368
// workflow code will always return the maxSupported version or version specified by GetVersionOption.
369-
// Make it not possible to test old version branch. With this mock support, it is possible to test code branch for different versions.
370369
//
371370
// Note: mock can be setup for a specific changeID. Or if mock.Anything is used as changeID then all calls to GetVersion
372371
// will be mocked. Mock for a specific changeID has higher priority over mock.Anything.

workflow/workflow.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ const DefaultVersion Version = internal.DefaultVersion
368368
// Following the steps below, your changes will be forward and backward compatible, keeping possible a safe rollback
369369
// to the previous version of the workflow code:
370370
//
371-
// 1. Keep execution of foo activity, add a support of bar activity
371+
// 1. Keep execution of foo activity, add support for bar activity
372372
//
373373
// v := GetVersion(ctx, "fooChange", DefaultVersion, 1, ExecuteWithVersion(DefaultVersion))
374374
// if v == DefaultVersion {
@@ -378,8 +378,9 @@ const DefaultVersion Version = internal.DefaultVersion
378378
// }
379379
//
380380
// The code above supports replaying of workflow execution with both versions DefaultVersion and 1.
381-
// All new workflow executions will execute foo activity, because GetVersion with ExecuteWithMinVersion option
382-
// returns DefaultVersion, that will be recorded into the workflow history.
381+
// All new workflow executions will execute foo activity, because ExecuteWithVersion(DefaultVersion)
382+
// causes GetVersion to return DefaultVersion rather than 1.
383+
// In this example, this is also exactly the same as using ExecuteWithMinVersion().
383384
//
384385
// 2. Enable execution of bar activity
385386
//
@@ -392,16 +393,14 @@ const DefaultVersion Version = internal.DefaultVersion
392393
//
393394
// The code above supports replaying of workflow execution with both versions DefaultVersion and 1.
394395
// All new workflow executions will execute bar activity, because
395-
// GetVersion returns the maximum supported version - 1, that will be recorded into the workflow history.
396+
// GetVersion returns the maximum supported version (1), which will be recorded into the workflow history.
396397
//
397398
// 3. Remove a support of foo activity:
398399
//
399400
// GetVersion(ctx, "fooChange", 1, 1)
400401
// err = workflow.ExecuteActivity(ctx, bar).Get(ctx, nil)
401402
//
402403
// When there are no workflow executions running DefaultVersion the support of foo activity can be removed.
403-
//
404-
// ExecuteWithVersion option is useful when you want to ensure that your changes can be safely rolled back if needed.
405404
func ExecuteWithVersion(version Version) internal.GetVersionOptions {
406405
return internal.ExecuteWithVersion(version)
407406
}

0 commit comments

Comments
 (0)