Skip to content

Commit 795bed8

Browse files
authored
Add helper function for GetBinaryChecksum (#991)
1 parent ccea6a6 commit 795bed8

File tree

5 files changed

+17
-10
lines changed

5 files changed

+17
-10
lines changed

internal/internal_task_handlers_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,9 @@ func (t *TaskHandlersTestSuite) TestWorkflowTask_BinaryChecksum() {
358358
t.NotNil(response)
359359
t.Equal(1, len(response.Decisions))
360360
t.Equal(s.DecisionTypeCompleteWorkflowExecution, response.Decisions[0].GetDecisionType())
361-
checksumsJSON := string(response.Decisions[0].CompleteWorkflowExecutionDecisionAttributes.Result)
361+
checksumsBytes := response.Decisions[0].CompleteWorkflowExecutionDecisionAttributes.Result
362362
var checksums []string
363-
json.Unmarshal([]byte(checksumsJSON), &checksums)
363+
json.Unmarshal(checksumsBytes, &checksums)
364364
t.Equal(3, len(checksums))
365365
t.Equal("chck1", checksums[0])
366366
t.Equal("chck2", checksums[1])

internal/internal_worker_interfaces_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,13 @@ func querySignalWorkflowFunc(ctx Context, numSignals int) error {
112112
return nil
113113
}
114114

115-
func binaryChecksumWorkflowFunc(ctx Context) ([]*string, error) {
116-
var result []*string
117-
result = append(result, GetWorkflowInfo(ctx).BinaryChecksum)
115+
func binaryChecksumWorkflowFunc(ctx Context) ([]string, error) {
116+
var result []string
117+
result = append(result, GetWorkflowInfo(ctx).GetBinaryChecksum())
118118
Sleep(ctx, time.Hour)
119-
result = append(result, GetWorkflowInfo(ctx).BinaryChecksum)
119+
result = append(result, GetWorkflowInfo(ctx).GetBinaryChecksum())
120120
Sleep(ctx, time.Hour)
121-
result = append(result, GetWorkflowInfo(ctx).BinaryChecksum)
121+
result = append(result, GetWorkflowInfo(ctx).GetBinaryChecksum())
122122
return result, nil
123123
}
124124

internal/workflow.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,13 @@ type WorkflowInfo struct {
740740
BinaryChecksum *string
741741
}
742742

743+
func (wInfo *WorkflowInfo) GetBinaryChecksum() string {
744+
if wInfo.BinaryChecksum == nil {
745+
return getBinaryChecksum()
746+
}
747+
return *wInfo.BinaryChecksum
748+
}
749+
743750
// GetWorkflowInfo extracts info of a current workflow from a context.
744751
func GetWorkflowInfo(ctx Context) *WorkflowInfo {
745752
i := getWorkflowInterceptor(ctx)

test/integration_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const (
6161
ctxTimeout = 15 * time.Second
6262
domainName = "integration-test-domain"
6363
domainCacheRefreshInterval = 20 * time.Second
64-
testContextKey = "test-context-key"
64+
testContextKey = "test-context-key"
6565
)
6666

6767
func TestIntegrationSuite(t *testing.T) {
@@ -149,7 +149,7 @@ func (ts *IntegrationTestSuite) SetupTest() {
149149
DisableStickyExecution: ts.config.IsStickyOff,
150150
Logger: logger,
151151
WorkflowInterceptorChainFactories: []interceptors.WorkflowInterceptorFactory{ts.tracer},
152-
ContextPropagators: []workflow.ContextPropagator{NewStringMapPropagator([]string{testContextKey})},
152+
ContextPropagators: []workflow.ContextPropagator{NewStringMapPropagator([]string{testContextKey})},
153153
}
154154
ts.worker = worker.New(ts.rpcClient.Interface, domainName, ts.taskListName, options)
155155
ts.registerWorkflowsAndActivities(ts.worker)

test/test_utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import (
3636

3737
type (
3838
// Config contains the integration test configuration
39-
Config struct {
39+
Config struct {
4040
ServiceAddr string
4141
ServiceName string
4242
IsStickyOff bool

0 commit comments

Comments
 (0)