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

Documentation: How to do unit testing #1549

Open
sporto opened this Issue Feb 8, 2018 · 4 comments

Comments

Projects
None yet
5 participants
@sporto

sporto commented Feb 8, 2018

What are you trying to accomplish?

I'm building a web server using Diesel. I want to unit test my code that access the DB via diesel. But I'm finding it unclear how to do this.

What is the expected output?

A documentation guide that explain best practices for unit testing while using Diesel and how to.

For example if I choose to hit the DB, how to clean it before each test, or run tests in transactions. Maybe something about factories.

If I would like to mock db call, how to achieve this.

@sporto sporto changed the title from Documentation: How to do unit test to Documentation: How to do unit testing Feb 8, 2018

@rajcspsg

This comment has been minimized.

rajcspsg commented Mar 11, 2018

Hi - Can I work on this documentation issue and submit PR?

@sgrif

This comment has been minimized.

Member

sgrif commented Mar 14, 2018

Sure.

@joelgallant

This comment has been minimized.

joelgallant commented Oct 1, 2018

@rajcspsg did you end up creating anything for this?

@weiznich

This comment has been minimized.

Contributor

weiznich commented Oct 1, 2018

@joelgallant Try looking into diesels own test suit for examples how to write unit tests.
It basically boils down to have a function to create connection somewhere and calling begin_test_transaction on that connection before returning it to the test case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment