Git Product home page Git Product logo

Comments (8)

andreynering avatar andreynering commented on June 10, 2024

Hi @richard-to,

Great to know it kinda already works!

I think it's just a matter adding pgx to this switch as you said, and making sure there's a test for it.

from testfixtures.

richard-to avatar richard-to commented on June 10, 2024

Ok, great, I'll see if I can spin up a pull request next time I get the chance.

from testfixtures.

andreynering avatar andreynering commented on June 10, 2024

Closed as part of #74.

from testfixtures.

ChiliConSql avatar ChiliConSql commented on June 10, 2024

Hey guys, do you have an example of how to use this in code?

from testfixtures.

richard-to avatar richard-to commented on June 10, 2024

Hey guys, do you have an example of how to use this in code?

I believe you can set "pgx" as the dialect.

Here's a snippet from the readme.md that I modified:

        fixtures, err = testfixtures.New(
                testfixtures.Database(db), // You database connection
                testfixtures.Dialect("pgx"),
                testfixtures.Directory("testdata/fixtures"), // the directory containing the YAML files
        )

There's a comment there that says: // Available: "postgresql", "timescaledb", "mysql", "mariadb", "sqlite" and "sqlserver" So that can be updated I think to include pgx.

from testfixtures.

ChiliConSql avatar ChiliConSql commented on June 10, 2024

Thank you @richard-to . My confusion was how to get the "db" connection. It has to be stdlib.Conn and not pgx.Conn, correct?

from testfixtures.

richard-to avatar richard-to commented on June 10, 2024

Yes, you're right. You'll have to use database/sql with the pgx dialect . This should be fine since it's only for doing simple operations to manage the fixtures.

I do something like this in my code:

db, err = sql.Open(testConfig.Database.Dialect(), testConfig.Database.ConnectionInfo())

Then for my tests I use pgx directly. In my case I use pgxpool.

pool, err = pgxpool.Connect(context.Background(), testConfig.Database.ConnectionInfo())

from testfixtures.

richard-to avatar richard-to commented on June 10, 2024

Though I guess if you're using some very specific postgres features that don't work with database/sql, then this approach may not work

from testfixtures.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.