Diesel: Add integration tests for examples

Created on 4 Mar 2017  路  6Comments  路  Source: diesel-rs/diesel

We currently have the app from the Getting Started guide implemented for all backends, but there are no tests to ensure they all behave the same.

The app implements several simple binaries to create/display/publish/delete posts. Writings some tests that interact with _all_ the binaries and assert their output is good would be great (it doesn't even have to cover all failure cases).

I wrote the assert_cli crate for a similar use-case. There might be better crates for that now, though. Or actually, it might be possible to do that in a shell script. (Don't know how well that works on Windows, though.)

good first issue help wanted tests

All 6 comments

Hi,

I'd like to get familiar with this project so I want to help with this issue.
If I understand correctly, for all the examples in the examples directory a test needs to be written to confirm that they are all working properly. So, besides verifying that the binaries output is good, would this also include checking that the database is in expected state after every step?

This could be written as a Rust integration test or is something like .py script for each backend more preferable?

I'm interested in this issue because I'm trying to figure out how to test my own application that uses diesel. Will I have to run my own CI server with a DB to connect to and verify after every command? There has to be a better way.

Hopefully tests in the examples will give me an idea.

Since there hasn't been any activity on this since 2017, I'd like to tackle this issue 馃槃

@heyztb sure, go for it! Maybe open a PR with a rough idea what you want to test and then iterate on that? This way, we can give you feedback as early as possible. Alternatively, feel free to ask questions here or (preferred) on Gitter.

@killercup - Sounds good. I'll open a PR once I've got a tentative test up and running. I'm going to work on the Postgres example first, mainly because I'm not sure exactly which library I need to install in order to work with MySQL (I'm on macOS Mojave, btw).

I do have a question, and I figured this would be an appropriate place to ask but I'm also going to link this issue to the Gitter channel and get some feedback there -

I understand that this issue asks for Integration tests, and I've taken a look at the assert_cmd crate, but I'm not too sure how I'd pass in arguments to the various binaries. I'd rather the tests not require actual user input, and I would like to simulate that instead. My question is, how do I go about passing in things like the title and body of a post in my tests? There's no straightforward way from what I can tell, so are we sure that unit tests aren't more appropriate for this? Thanks for the help. I look forward to contributing more!

@heyztb cool!

Very good question regarding the interativity! I actually totally forgot about that. It would be nice to test that, but it's totally fine to start with unit tests: We are trying to make sure the diesel examples are fine, not that stdin works, after all :)

In my capacity as author of assert_cli and CLI working group lead, I am very interested in making sure we _can_ write those tests, however! There is https://github.com/assert-rs/assert_cmd/issues/28 which tracks this in some fashion. For all things CLI (testing or otherwise) you are also very welcome to join https://gitter.im/rust-lang/WG-CLI (or #cli-wg on the rust-lang discord) and to ping me directly.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

killercup picture killercup  路  4Comments

pjenvey picture pjenvey  路  4Comments

ivan picture ivan  路  4Comments

kollapsderwellenfunktion picture kollapsderwellenfunktion  路  4Comments

astraw picture astraw  路  4Comments