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

Add integration tests for examples #777

Open
killercup opened this issue Mar 4, 2017 · 6 comments
Open

Add integration tests for examples #777

killercup opened this issue Mar 4, 2017 · 6 comments

Comments

@killercup
Copy link
Member

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.)

@ivan-brko
Copy link

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?

@cgm616
Copy link

cgm616 commented Apr 20, 2017

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.

@heyztb
Copy link

heyztb commented Oct 5, 2018

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

@killercup
Copy link
Member Author

@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.

@heyztb
Copy link

heyztb commented Oct 5, 2018

@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!

@killercup
Copy link
Member Author

@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 assert-rs/assert_cmd#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.

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

No branches or pull requests

4 participants