Skip to content

Commit

Permalink
TestKit backend: except txMeta as Cypher types (#414)
Browse files Browse the repository at this point in the history
Co-authored-by: Florent Biville <florent.biville@neo4j.com>
  • Loading branch information
robsdedude and fbiville authored Dec 15, 2022
1 parent 127bbf8 commit 2bc8eb7
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions testkit-backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ 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 {
txMetadata, err := b.toParams(data["txMeta"].(map[string]any))
if err != nil {
panic(err)
}
txConfig.Metadata = txMetadata
Expand All @@ -268,15 +268,25 @@ 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)
var err error
for i, p := range params {
if params[i], err = cypherToNative(p); err != nil {
return "", nil, err
rawParameters, _ := data["params"].(map[string]any)
parameters, err := b.toParams(rawParameters)
if err != nil {
return "", nil, err
}
query := data["cypher"].(string)
return query, parameters, nil
}

func (b *backend) toParams(parameters map[string]any) (map[string]any, error) {
result := make(map[string]any, len(parameters))
for name, rawParam := range parameters {
param, err := cypherToNative(rawParam)
if err != nil {
return nil, err
}
result[name] = param
}
return cypher, params, nil
return result, nil
}

func (b *backend) handleTransactionFunc(isRead bool, data map[string]any) {
Expand Down

0 comments on commit 2bc8eb7

Please sign in to comment.