Skip to content

Cargo test doesn't run diesel migrations until the all target #762

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

Closed
jtgeibel opened this issue Jun 8, 2017 · 0 comments
Closed

Cargo test doesn't run diesel migrations until the all target #762

jtgeibel opened this issue Jun 8, 2017 · 0 comments

Comments

@jtgeibel
Copy link
Member

jtgeibel commented Jun 8, 2017

On the contributing page under running the background tests it states that "The test harness will ensure that migrations are run". However, when attempting to run the tests for the first time I get errors from the cargo_registry target because the database tables don't exist yet.

I manually ran the migrations and then reverted the final migration. I then see it running the last migration as part of the all target, which is the last batch of tests to run.

sgrif added a commit to sgrif/crates.io that referenced this issue Jun 9, 2017
While we're running these in the integration tests, they weren't run
before unit tests. Rather than duplicating the logic for this everywhere
that we have a test that interacts with the database, we can just do
this at compile time.

As best I can tell, Cargo doesn't give you any environment variable to
know that you're building for tests and not just a debug build, so I've
set this up to only try to migrate if the env var is present, and not
error in its absense.

Fixes rust-lang#762.
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

No branches or pull requests

1 participant