1 Star 0 Fork 0

/flow-engine

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
engine_test.go 1.92 KB
一键复制 编辑 原始数据 按行查看 历史
陈昞翱 提交于 2021-08-21 15:43 . save
package flow_engine
import (
"fmt"
"gitee.com/whit/flow-engine/model"
"testing"
)
func getDefaultTestEngine() *FlowEngine {
cfg := &Config{
Mysql: struct{ Datasource string }{
Datasource: "root:123456@tcp(10.10.10.200:23306)/oatest-flowengine?charset=utf8&parseTime=true&loc=Asia%2FShanghai",
},
}
return NewFlowEngine(cfg, func(event Event, taskId int64, engine *FlowEngine) {
fmt.Println(event, taskId)
}, func(inst *model.ProcInst, engine *FlowEngine) {
fmt.Println(json.Marshal(inst))
}, func(roleId string) (*User, error) {
return &User{
Id: "1",
Name: "诸葛掘机",
}, nil
}, func(userId string, level int) (*User, error) {
return &User{
Id: "2",
Name: "诸葛建国",
}, nil
}, func(taskKey string, forms []string) (string, error) {
return forms[0], nil
})
}
func TestFlowEngine_AddProcDef(t *testing.T) {
engine := getDefaultTestEngine()
def := model.ProcDefNode{
Type: model.NtStart,
NextNodes: append(make([]model.ProcDefNode, 0), model.ProcDefNode{
Type: model.NtTask,
Prop: &model.ProcDefNodeProp{
Name: "主管审批",
Key: "leave_request",
Desc: "请假条审批",
Actors: append(make([]model.ProcDefActor, 0), model.ProcDefActor{
Id: "1",
Type: model.AtUser,
Name: "诸葛掘机",
}),
},
NextNodes: append(make([]model.ProcDefNode, 0), model.ProcDefNode{
Type: model.NtEnd,
}),
}),
}
_, err := engine.AddProcDef(&model.ProcDef{
Key: "leave_req",
Group: "0",
Title: "请假审批",
Content: def.ToJsonStr(),
})
if err != nil {
t.Error(err)
}
}
func TestFlowEngine_StartProcess(t *testing.T) {
engine := getDefaultTestEngine()
id, err := engine.StartProcess("5", 1, "{\"title\":\"测试表单\"}")
if err != nil {
t.Error(err)
}
print(id)
}
func TestFlowEngine_UpdateProcDef(t *testing.T) {
//engine := getDefaultTestEngine()
//if err := engine
}
func TestFlowEngine_DelProcDef(t *testing.T) {
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/whit/flow-engine.git
[email protected]:whit/flow-engine.git
whit
flow-engine
flow-engine
master

搜索帮助