mirror of
https://github.com/aceld/kis-flow.git
synced 2025-01-23 07:30:23 +08:00
102 lines
2.3 KiB
Go
102 lines
2.3 KiB
Go
package test
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"kis-flow/file"
|
|
"kis-flow/kis"
|
|
"testing"
|
|
)
|
|
|
|
func TestActionAbort(t *testing.T) {
|
|
ctx := context.Background()
|
|
|
|
// 1. 加载配置文件并构建Flow
|
|
if err := file.ConfigImportYaml("/Users/Aceld/go/src/kis-flow/test/load_conf/"); err != nil {
|
|
fmt.Println("Wrong Config Yaml Path!")
|
|
panic(err)
|
|
}
|
|
|
|
// 2. 获取Flow
|
|
flow1 := kis.Pool().GetFlow("flowName2")
|
|
|
|
// 3. 提交原始数据
|
|
_ = flow1.CommitRow("This is Data1 from Test")
|
|
_ = flow1.CommitRow("This is Data2 from Test")
|
|
_ = flow1.CommitRow("This is Data3 from Test")
|
|
|
|
// 4. 执行flow1
|
|
if err := flow1.Run(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func TestActionDataReuse(t *testing.T) {
|
|
ctx := context.Background()
|
|
|
|
// 1. 加载配置文件并构建Flow
|
|
if err := file.ConfigImportYaml("/Users/Aceld/go/src/kis-flow/test/load_conf/"); err != nil {
|
|
fmt.Println("Wrong Config Yaml Path!")
|
|
panic(err)
|
|
}
|
|
|
|
// 2. 获取Flow
|
|
flow1 := kis.Pool().GetFlow("flowName3")
|
|
|
|
// 3. 提交原始数据
|
|
_ = flow1.CommitRow("This is Data1 from Test")
|
|
_ = flow1.CommitRow("This is Data2 from Test")
|
|
_ = flow1.CommitRow("This is Data3 from Test")
|
|
|
|
// 4. 执行flow1
|
|
if err := flow1.Run(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func TestActionForceEntry(t *testing.T) {
|
|
ctx := context.Background()
|
|
|
|
// 1. 加载配置文件并构建Flow
|
|
if err := file.ConfigImportYaml("/Users/Aceld/go/src/kis-flow/test/load_conf/"); err != nil {
|
|
fmt.Println("Wrong Config Yaml Path!")
|
|
panic(err)
|
|
}
|
|
|
|
// 2. 获取Flow
|
|
flow1 := kis.Pool().GetFlow("flowName4")
|
|
|
|
// 3. 提交原始数据
|
|
_ = flow1.CommitRow("This is Data1 from Test")
|
|
_ = flow1.CommitRow("This is Data2 from Test")
|
|
_ = flow1.CommitRow("This is Data3 from Test")
|
|
|
|
// 4. 执行flow1
|
|
if err := flow1.Run(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func TestActionJumpFunc(t *testing.T) {
|
|
ctx := context.Background()
|
|
|
|
// 1. 加载配置文件并构建Flow
|
|
if err := file.ConfigImportYaml("/Users/Aceld/go/src/kis-flow/test/load_conf/"); err != nil {
|
|
fmt.Println("Wrong Config Yaml Path!")
|
|
panic(err)
|
|
}
|
|
|
|
// 2. 获取Flow
|
|
flow1 := kis.Pool().GetFlow("flowName5")
|
|
|
|
// 3. 提交原始数据
|
|
_ = flow1.CommitRow("This is Data1 from Test")
|
|
_ = flow1.CommitRow("This is Data2 from Test")
|
|
_ = flow1.CommitRow("This is Data3 from Test")
|
|
|
|
// 4. 执行flow1
|
|
if err := flow1.Run(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|