Skip to content

Is there a method that doesn't alter the original connection pool ? #154

Answered by pashagolub
kizuna-lek asked this question in Q&A
Discussion options

You must be logged in to vote

Hello, and thanks for your interest.

Do I must modify my structure in this way?

Well, you don't need to use pgxmock.PgxIface. It's possible, but I would recommend something other than that for one reason: you don't want to use anything from the testing environment in your production build. To overcome this problem, you may define and use your own interface. As a start, you may copy-paste PgxPoolIface and PgxIface into your code. You can even rename it. The main thing is that this interface will define the methods of the pool.

Check my own implementation of this technique in pg_timetable.

Is it necessary and feasible to implement such a modification?

We can mock only interfaces. Because

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@kizuna-lek
Comment options

Answer selected by kizuna-lek
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
2 participants
Converted from issue

This discussion was converted from issue #153 on August 18, 2023 12:44.