-
-
Notifications
You must be signed in to change notification settings - Fork 439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Looking for a way to mock tokio_postgres::Client ? #1119
Comments
You could make your own trait and implement it for Client. |
Thanks for the reply. You're right that I could duplicate all of the code in GenericClient and thus have my own trait that was the same without the [edit for clarification] It seems like you've intentionally/explicitly made this code hard to test; why is that? Would you be open to a PR to remove that Thanks in advance. |
Hi - thanks for the great project.
Per the title, I'm trying to create a Mock Client so I can test my code without having to setup a real DB. How have other people done this?
Looking at the code, it seems like implementing GenericClient would be a great path, but it extends
private::Sealed
explicitly preventing that. Another avenue would be to implement anInnerClient
and pass that to a new client, but both the InnerClient trait and theClient::new()
functions are not accessible outside of the crate.If there aren't any easy paths for this, could I offer to create a Mock function that looks like:
https://docs.rs/tokio-postgres/latest/src/tokio_postgres/client.rs.html#189
Let me know and thank you in advance!
The text was updated successfully, but these errors were encountered: