From 330189d2638ac996939562da8cb109ee532e881a Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Thu, 14 Nov 2024 16:25:58 -0800 Subject: [PATCH] forgot updateworkflowbyid --- internal/internal_workflow_testsuite.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/internal/internal_workflow_testsuite.go b/internal/internal_workflow_testsuite.go index c70bb44f8..b0a5b5b35 100644 --- a/internal/internal_workflow_testsuite.go +++ b/internal/internal_workflow_testsuite.go @@ -2962,17 +2962,26 @@ func (env *testWorkflowEnvironmentImpl) updateWorkflowByID(workflowID, name, id panic(err) } + if env.updateMap == nil { + env.updateMap = make(map[string]updateResult) + } + var ucWrapper = updateCallbacksWrapper{uc: uc, env: env, updateID: id} // Check for duplicate update ID if result, ok := env.updateMap[id]; ok { + result.mu.Lock() workflowHandle.env.postCallback(func() { ucWrapper.uc.Accept() ucWrapper.uc.Complete(result.success, result.err) + defer result.mu.Unlock() }, false) } else { + env.updateMap[id] = updateResult{nil, nil, &sync.Mutex{}} + env.updateMap[id].mu.Lock() workflowHandle.env.postCallback(func() { workflowHandle.env.updateHandler(name, id, data, nil, ucWrapper) + defer env.updateMap[id].mu.Unlock() }, true) }