feat: Support for specifying multiple databases in test macros. #4050
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.
This makes it possible to specify multiple databases with the
sqlx::test
macro.Adds grouping by
env
and specification of environment variable names byvar
as macro arguments.This makes it easier to write tests for the following cases:
Sharded databases
Multiple types of databases (for example, the case below).
Uses Sqlite as local master data and stores variable data in remote PostgreSQL.
A relational database and a relational-compatible NoSQL database.
Concerns
Are the argument names
env
andvar
ambiguous?Other changes.
TestArgs::no_migrator
to simplify macro implementation.TestArgs::database_url_var
to save the environment variable name when running tests.cleanup_test_dbs_by_url
function toTestSupport
, which deletes test databases from the database_url argument.TestFn
with a macro, but this is not done as this is intended to be a reference implementation for macro implementation.Does your PR solve an issue?
closes #2220
closes #3947
Is this a breaking change?
Yes.
TestSupport::cleanup_test
will be changed to takeTestArgs
as an argument.