SQLX Database tester

pipeline status coverage report docs main

This library makes it possible to create rust test cases for unit / integration testing with database access to unique databases per test case.

Each database is created with the database name generated as UUID v4, to prevent any collision between test cases.

The sqlx database pool variable of requested name is exposed to the test function scope.

The macro allows for creation and exposure of multiple databases per test function if needed.

Usage:

```rust

[sqlxdatabasetester::test(

pool(variable = "default_migrated_pool"),
pool(variable = "migrated_pool", migrations = "./test_migrations"),
pool(variable = "empty_db_pool", 
     transaction_variable = "empty_db_transaction", 
     skip_migrations),

)] async fn testserverstart() { let migratedpooltables = sqlx::query!("SELECT * FROM pgcatalog.pgtables") .fetchall(&migratedpool) .await .unwrap(); let emptypooltables = sqlx::query!("SELECT * FROM pgcatalog.pgtables") .fetchall(&emptydbpool) .await .unwrap(); println!("Migrated pool tables: \n {:#?}", migratedpooltables); println!("Empty pool tables: \n {:#?}", emptypool_tables); } ```

Macro attributes:

Pre-commit usage

  1. If not installed, install with your package manager, or pip install --user pre-commit
  2. Run pre-commit autoupdate to update the pre-commit config to use the newest template
  3. Run pre-commit install to install the pre-commit hooks to your local environment

Famedly

This project is part of the source code of Famedly.

We think that software for healthcare should be open source, so we publish most parts of our source code at gitlab.com/famedly.

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

For licensing information of this project, have a look at the LICENSE file within the repository.

If you compile the open source software that we make available to develop your own mobile, desktop or embeddable application, and cause that application to connect to our servers for any purposes, you have to aggree to our Terms of Service. In short, if you choose to connect to our servers, certain restrictions apply as follows:

No license is granted to the Famedly trademark and its associated logos, all of which will continue to be owned exclusively by Famedly GmbH. Any use of the Famedly trademark and/or its associated logos is expressly prohibited without the express prior written consent of Famedly GmbH.

For more information take a look at Famedly.com or contact us by info@famedly.com