kis-flow/test/kis_function_test.go

39 lines
944 B
Go
Raw Normal View History

2024-01-01 17:49:27 +08:00
package test
2023-12-31 18:04:28 +08:00
import (
"context"
2024-03-26 14:54:50 +08:00
"github.com/aceld/kis-flow/common"
"github.com/aceld/kis-flow/config"
"github.com/aceld/kis-flow/flow"
"github.com/aceld/kis-flow/function"
2023-12-31 18:04:28 +08:00
"testing"
)
func TestNewKisFunction(t *testing.T) {
ctx := context.Background()
// 1. 创建一个KisFunction配置实例
source := config.KisSource{
Name: "公众号抖音商城户订单数据",
Must: []string{"order_id", "user_id"},
}
2024-01-03 10:16:54 +08:00
myFuncConfig1 := config.NewFuncConfig("funcName1", common.C, &source, nil)
2023-12-31 18:04:28 +08:00
if myFuncConfig1 == nil {
panic("myFuncConfig1 is nil")
}
// 2. 创建一个 KisFlow 配置实例
2024-01-03 10:16:54 +08:00
myFlowConfig1 := config.NewFlowConfig("flowName1", common.FlowEnable)
2023-12-31 18:04:28 +08:00
// 3. 创建一个KisFlow对象
flow1 := flow.NewKisFlow(myFlowConfig1)
// 4. 创建一个KisFunction对象
2024-01-01 17:49:27 +08:00
func1 := function.NewKisFunction(flow1, myFuncConfig1)
2023-12-31 18:04:28 +08:00
if err := func1.Call(ctx, flow1); err != nil {
t.Errorf("func1.Call() error = %v", err)
}
}