Skip to content

Commit

Permalink
added sanity check in remove rels function
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Solender committed Jun 3, 2022
1 parent 1a6070d commit d94011e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion save.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,13 @@ func removeRelations(transaction neo4j.Transaction, dels map[int64][]int64) erro

var params []interface{}

expectedDels := 0
for id, ids := range dels {
params = append(params, map[string]interface{}{
"startNodeId": id,
"endNodeIds": ids,
})
expectedDels += len(ids)
}

cyq, err := dsl.QB().
Expand Down Expand Up @@ -299,8 +301,17 @@ func removeRelations(transaction neo4j.Transaction, dels map[int64][]int64) erro
} else if err = res.Err(); err != nil {
return fmt.Errorf("%s: %w", err.Error(), ErrInternal)
}
//todo sanity check to make sure the affects worked

summary, err := res.Consume()
if err != nil {
return fmt.Errorf("failed to consume result summary, %s: %w", err.Error(), ErrInternal)
}

actualRelsDeleted := summary.Counters().RelationshipsDeleted()
if expectedDels != actualRelsDeleted {
return fmt.Errorf("expected relationship deletions not equal to actual. Expected=%v|Actual=%v", expectedDels, actualRelsDeleted)
}

return nil
}

Expand Down

0 comments on commit d94011e

Please sign in to comment.