🔥A cross-language distributed transaction manager. Support xa, tcc, saga, transactional messages. 跨语言分布式事务管理器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

34 lines
1.0 KiB

package test
import (
"testing"
"github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/client/workflow"
"github.com/dtm-labs/dtm/test/busi"
"github.com/stretchr/testify/assert"
)
func TestWorkflowRet(t *testing.T) {
workflow.SetProtocolForTest(dtmimp.ProtocolHTTP)
req := busi.GenReqHTTP(30, false, false)
gid := dtmimp.GetFuncName()
workflow.Register2(gid, func(wf *workflow.Workflow, data []byte) ([]byte, error) {
var req busi.ReqHTTP
dtmimp.MustUnmarshal(data, &req)
_, err := wf.NewBranch().NewRequest().SetBody(req).Post(Busi + "/TransOut")
return []byte("result of workflow"), err
})
ret, err := workflow.Execute2(gid, gid, dtmimp.MustMarshal(req))
assert.Nil(t, err)
assert.Equal(t, "result of workflow", string(ret))
assert.Equal(t, StatusSucceed, getTransStatus(gid))
// the second execute will return result directly
ret, err = workflow.Execute2(gid, gid, dtmimp.MustMarshal(req))
assert.Nil(t, err)
assert.Equal(t, "result of workflow", string(ret))
assert.Equal(t, StatusSucceed, getTransStatus(gid))
}