kis-flow/test/kis_config_test.go

90 lines
1.9 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 (
2024-04-16 15:11:23 +08:00
"testing"
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/log"
2023-12-30 17:38:08 +08:00
)
2024-01-03 10:16:54 +08:00
func TestNewFuncConfig(t *testing.T) {
source := config.KisSource{
2024-04-15 17:50:02 +08:00
Name: "TikTokOrder",
2024-01-03 10:16:54 +08:00
Must: []string{"order_id", "user_id"},
}
option := config.KisFuncOption{
2024-03-01 16:29:07 +08:00
CName: "connectorName1",
RetryTimes: 3,
RetryDuration: 300,
2024-01-03 10:16:54 +08:00
Params: config.FParam{
"param1": "value1",
"param2": "value2",
},
}
myFunc1 := config.NewFuncConfig("funcName1", common.S, &source, &option)
2024-04-15 11:17:47 +08:00
log.Logger().InfoF("funcName1: %+v\n", myFunc1)
2024-01-03 10:16:54 +08:00
}
2023-12-31 10:50:01 +08:00
func TestNewFlowConfig(t *testing.T) {
2024-01-01 17:49:27 +08:00
flowFuncParams1 := config.KisFlowFunctionParam{
2024-01-03 10:16:54 +08:00
FuncName: "funcName1",
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{
2024-01-03 10:16:54 +08:00
FuncName: "funcName2",
2024-01-01 17:49:27 +08:00
Params: config.FParam{
2023-12-31 10:50:01 +08:00
"default": "value1",
},
}
2024-01-03 10:16:54 +08:00
myFlow1 := config.NewFlowConfig("flowName1", common.FlowEnable)
2023-12-31 10:50:01 +08:00
myFlow1.AppendFunctionConfig(flowFuncParams1)
myFlow1.AppendFunctionConfig(flowFuncParams2)
2024-04-15 11:17:47 +08:00
log.Logger().InfoF("myFlow1: %+v\n", myFlow1)
2023-12-31 10:50:01 +08:00
}
2023-12-31 11:45:47 +08:00
func TestNewConnConfig(t *testing.T) {
2024-01-01 17:49:27 +08:00
source := config.KisSource{
2024-04-15 17:50:02 +08:00
Name: "TikTokOrder",
2023-12-31 11:45:47 +08:00
Must: []string{"order_id", "user_id"},
}
2024-01-01 17:49:27 +08:00
option := config.KisFuncOption{
2024-03-01 16:29:07 +08:00
CName: "connectorName1",
RetryTimes: 3,
RetryDuration: 300,
2023-12-31 11:45:47 +08:00
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-03 10:16:54 +08:00
myFunc1 := config.NewFuncConfig("funcName1", common.S, &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-03 10:16:54 +08:00
myConnector1 := config.NewConnConfig("connectorName1", "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 {
2024-04-15 11:17:47 +08:00
log.Logger().ErrorF("WithFunc err: %s\n", err.Error())
2023-12-31 11:45:47 +08:00
}
2024-04-15 11:17:47 +08:00
log.Logger().InfoF("myConnector1: %+v\n", myConnector1)
2023-12-31 11:45:47 +08:00
}