Skip to content
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

Introduce RowBuilder to support writing basic unit tests #979

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hunts
Copy link

@hunts hunts commented Jan 5, 2023

Added RowDescription trait, and let rows to share the same description rather than having a copy in each row (think when there are thousand of them in the result).

Added RowBuilder to support adding stubs of row data in unit tests.

Currently, the library users have no chooice but have to use integration tests for testing Postgres data access code. With the changes in this commit, the tokio-postgres lib users can use RowBuilder to create sutbs to verify the deserialization from database result (Rows) to custom stucts in unit tests.

It can also serves as a base for future implementation of certain kind of mocks of the db connection.

Related-to #910 #950

Added RowDescription trait, and let rows to share the same description
rather than having a copy in each row (think when there are thousand of
them in the result).

Added RowBuilder to support adding stubs of row data in unit tests.

Currently, the library users have no chooice but have to use integration
tests for testing Postgres data access code. With the changes in this
commit, the `tokio-postgres` lib users can use RowBuilder to create
sutbs to verify the deserialization from database result (Rows) to
custom stucts in unit tests.

It can also serves as a base for future implementation of certain kind
of mocks of the db connection.

Related-to sfackler#910 sfackler#950
@hunts hunts force-pushed the hunts/add-basic-testability-for-lib-users branch from f712d07 to 07336e5 Compare January 5, 2023 21:37
@phyllipecesar
Copy link

Hi @sfackler ,

I usually create a struct and implement TryFrom<Row> for that struct, I rely on integration tests(which are usually more expensive) to test end to end.

Do you have any recommendation how to unit test conversions?
Thank you.

@deleted
Copy link

deleted commented Aug 22, 2023

I, too, need something like this for unit testing.
@sfackler Any thoughts on accepting this or something similar?

@owlot
Copy link

owlot commented Nov 8, 2023

I also need this, been watching the pr for a while, but seems like it's not going to be merged at all?

@deleted
Copy link

deleted commented Nov 28, 2023

Nothing to add except that the ability to synthesize Rows / a RowStream in unit testing is still very important to me.

Is this something we can expect to ever see in rust-postgres or no?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants