Skip to content

Unable to mock ManagedTransaction interface for testing #527

@adrianiacobghiula

Description

@adrianiacobghiula

Driver version: Go driver v5.12.0

Interfaces in neo4j package like ManagedTransaction have a "non-exported method" -> legacy() Transaction
https://github.com/neo4j/neo4j-go-driver/blob/5.0/neo4j/transaction_with_context.go#L33

If one would want to mock this ManagedTransaction interface will end up in errors like
Type cannot implement 'ManagedTransaction' as it has a non-exported method and is defined in a different package

it is not the only interface having these "non-exported method"(s)

Main issue appears trying to unit test something like
greeting, err := session.ExecuteWrite(ctx, func(transaction neo4j.ManagedTransaction) (any, error) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions