Skip to content

Mocking via a fake impl of GenericConnection #113

@tomc1998

Description

@tomc1998

Hey!

I'm trying to create a 'mock connection', which will let me pass a function a fake mysql connection and instead of reading an actual database, will just return fake data and record the SQL queries. This is to make unit tests run faster (i.e. not have to have actual database access)

However, the GenericConnection trait requires that I return Stmt, QueryResult objects etc which cannot be created without a real connection.

I was just wondering your thoughts on a better API for this kind of thing. Could we expose a new() method on Stmt, do you think? Or, have the GenericConnection methods return trait objects / enums with a fake value?

I wasn't sure of the best way of going about this, as I don't know the internals of the library all too well. A penny for your thoughts?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions