kis-flow/test/kis_config_test.go
2024-01-01 17:49:27 +08:00

89 lines
1.8 KiB
Go

package test
import (
"fmt"
"kis-flow/common"
"kis-flow/config"
"testing"
)
func TestNewFlowConfig(t *testing.T) {
flowFuncParams1 := config.KisFlowFunctionParam{
Fid: "funcId1",
Params: config.FParam{
"flowSetFunParam1": "value1",
"flowSetFunParam2": "value2",
},
}
flowFuncParams2 := config.KisFlowFunctionParam{
Fid: "funcId2",
Params: config.FParam{
"default": "value1",
},
}
myFlow1 := config.NewFlowConfig("flowId", "flowName", 1)
myFlow1.AppendFunctionConfig(flowFuncParams1)
myFlow1.AppendFunctionConfig(flowFuncParams2)
fmt.Printf("myFlow1: %+v\n", myFlow1)
}
func TestNewFuncConfig(t *testing.T) {
source := config.KisSource{
Name: "公众号抖音商城户订单数据",
Must: []string{"order_id", "user_id"},
}
option := config.KisFuncOption{
Cid: "connector_id",
RetryTimes: 3,
RetryDuriton: 300,
Params: config.FParam{
"param1": "value1",
"param2": "value2",
},
}
myFunc1 := config.NewFuncConfig("funcId", "funcName", "Save", &source, &option)
fmt.Printf("myFunc1: %+v\n", myFunc1)
}
func TestNewConnConfig(t *testing.T) {
source := config.KisSource{
Name: "公众号抖音商城户订单数据",
Must: []string{"order_id", "user_id"},
}
option := config.KisFuncOption{
Cid: "connector_id",
RetryTimes: 3,
RetryDuriton: 300,
Params: config.FParam{
"param1": "value1",
"param2": "value2",
},
}
myFunc1 := config.NewFuncConfig("funcId", "funcName", "Save", &source, &option)
connParams := config.FParam{
"param1": "value1",
"param2": "value2",
}
myConnector1 := config.NewConnConfig("connectorId", "connectorName", "0.0.0.0:9987,0.0.0.0:9997", common.REDIS, "key", connParams)
if err := myConnector1.WithFunc(myFunc1); err != nil {
fmt.Printf("WithFunc err: %s\n", err.Error())
}
fmt.Printf("myConnector1: %+v\n", myConnector1)
}