Use backend specific env vars if present for tests #644
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Having a single
DATABASE_URL
is really nice in contexts where you'relikely only using one backend. It makes a lot of sense for Travis, which
runs against one backend at a time. It also makes sense for CLI to
continue to default to it by convention, as it has to look at the URL to
figure out which backend to use.
However, for development on Diesel itself, we are switching between
different backends all the time. This didn't matter as much for SQLite,
since we can just give it some random file path and have it work (and
we're usually connecting to
:memory:
anyway). For MySQL though, weneed to be more concrete. Where applicable, our test suite will now look
for
PG_DATABASE_URL
, before falling back to justDATABASE_URL
. Thisdoes not apply to our examples, as they assume PG and set the
DATABASE_URL
manually inexamples/test_all
. This also doesn't applyto CLI's test suite, which sets
DATABASE_URL
manually as needed, sinceit can't run in a transaction and thus needs a different database
per-test.
So developers who frequently run our test suite against more than one
backend will likely have a
.env
file which looks like: