From ae14e53ec61d613dda5d3c67cdfc68f22e4bf874 Mon Sep 17 00:00:00 2001 From: Robsdedude Date: Wed, 7 Dec 2022 16:27:52 +0100 Subject: [PATCH] TestKit backend: except txMeta as Cypher types Depends on: * https://github.com/neo4j-drivers/testkit/pull/538 --- testkit-backend/backend.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/testkit-backend/backend.go b/testkit-backend/backend.go index 44cafc65..3442c2e7 100644 --- a/testkit-backend/backend.go +++ b/testkit-backend/backend.go @@ -247,8 +247,9 @@ func (b *backend) toTransactionConfigApply(data map[string]any) func(*neo4j.Tran txConfig := neo4j.TransactionConfig{Timeout: math.MinInt} // Optional transaction meta data if data["txMeta"] != nil { - txMetadata := data["txMeta"].(map[string]any) - if err := patchNumbersInMap(txMetadata); err != nil { + //toParams + txMetadata, err := b.toParams(data["txMeta"].(map[string]any)) + if err != nil { panic(err) } txConfig.Metadata = txMetadata @@ -268,15 +269,22 @@ func (b *backend) toTransactionConfigApply(data map[string]any) func(*neo4j.Tran } func (b *backend) toCypherAndParams(data map[string]any) (string, map[string]any, error) { - cypher := data["cypher"].(string) params, _ := data["params"].(map[string]any) + if param, err := b.toParams(params); err != nil { + return "", nil, err + } else { + return data["cypher"].(string), param, nil + } +} + +func (b *backend) toParams(params map[string]any) (map[string]any, error) { var err error for i, p := range params { if params[i], err = cypherToNative(p); err != nil { - return "", nil, err + return nil, err } } - return cypher, params, nil + return params, nil } func (b *backend) handleTransactionFunc(isRead bool, data map[string]any) {