2024-03-26 16:47:34 +08:00
|
|
|
package test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"github.com/aceld/kis-flow/file"
|
|
|
|
"github.com/aceld/kis-flow/kis"
|
|
|
|
"github.com/aceld/kis-flow/log"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestForkFlowCommitBatch(t *testing.T) {
|
|
|
|
ctx := context.Background()
|
|
|
|
|
2024-04-15 17:50:02 +08:00
|
|
|
// 1. Load the configuration file and build the Flow
|
2024-03-26 16:47:34 +08:00
|
|
|
if err := file.ConfigImportYaml("load_conf/"); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2024-04-15 17:50:02 +08:00
|
|
|
// 2. Get the Flow
|
2024-03-26 16:47:34 +08:00
|
|
|
flow1 := kis.Pool().GetFlow("flowName1")
|
|
|
|
|
|
|
|
stringRows := []string{
|
|
|
|
"This is Data1 from Test",
|
|
|
|
"This is Data2 from Test",
|
|
|
|
"This is Data3 from Test",
|
|
|
|
}
|
|
|
|
|
2024-04-15 17:50:02 +08:00
|
|
|
// 3. Commit raw data
|
2024-03-26 16:47:34 +08:00
|
|
|
if err := flow1.CommitRowBatch(stringRows); err != nil {
|
2024-04-15 11:17:47 +08:00
|
|
|
log.Logger().ErrorF("CommitRowBatch Error, err = %+v", err)
|
2024-03-26 16:47:34 +08:00
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2024-04-15 17:50:02 +08:00
|
|
|
// 4. Execute flow1
|
2024-03-26 16:47:34 +08:00
|
|
|
if err := flow1.Run(ctx); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|