feat: simplify SOP to immediate-effect configuration
This commit is contained in:
24
internal/run/mapping_test.go
Normal file
24
internal/run/mapping_test.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package run
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"git.iwork-ai.com/xdc/iqudo-top1/internal/model"
|
||||
)
|
||||
|
||||
func TestMapScenarioInputSupportsArrays(t *testing.T) {
|
||||
fields := []model.ScenarioField{{FieldKey: "customer_name", SourcePath: "customer.name"}, {FieldKey: "product_ids", SourcePath: "order.items[*].product_id"}}
|
||||
input := map[string]interface{}{"customer": map[string]interface{}{"name": "王女士"}, "order": map[string]interface{}{"items": []interface{}{map[string]interface{}{"product_id": "P1"}, map[string]interface{}{"product_id": "P2"}}}}
|
||||
want := map[string]interface{}{"customer_name": "王女士", "product_ids": []interface{}{"P1", "P2"}}
|
||||
if got := mapScenarioInput(fields, input); !reflect.DeepEqual(got, want) {
|
||||
t.Fatalf("mapped input = %#v, want %#v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMergeValuesUsesExplicitValues(t *testing.T) {
|
||||
got := mergeValues(map[string]interface{}{"name": "mapped"}, map[string]interface{}{"name": "explicit"})
|
||||
if got["name"] != "explicit" {
|
||||
t.Fatalf("name = %v", got["name"])
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user