kis-flow/test/kis_config_test.go

89 lines
1.8 KiB
Go
Raw Normal View History

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