From de56be0c5288e5252da87ccd2bc0c2de9d17afaf Mon Sep 17 00:00:00 2001 From: Jose Celano Date: Mon, 8 May 2023 16:34:34 +0100 Subject: [PATCH] refactor: move docs and compose config for database tests Those files are only realted to `tests\database` tests. --- tests/README.md | 21 ----------- tests/databases/README.md | 47 ++++++++++++++++++++++++ tests/{ => databases}/docker-compose.yml | 0 3 files changed, 47 insertions(+), 21 deletions(-) delete mode 100644 tests/README.md create mode 100644 tests/databases/README.md rename tests/{ => databases}/docker-compose.yml (100%) diff --git a/tests/README.md b/tests/README.md deleted file mode 100644 index 2cad69c7..00000000 --- a/tests/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# Running Tests - -Torrust requires Docker to run different database systems for testing. [Install docker here](https://docs.docker.com/engine/). - -Start the databases with `docker-compose` before running tests: - -```s -docker-compose -f tests/docker-compose.yml up -``` - -Run all tests using: - -```s -cargo test -``` - -Connect to the DB using MySQL client: - -```s -mysql -h127.0.0.1 -uroot -ppassword torrust-index_test -``` diff --git a/tests/databases/README.md b/tests/databases/README.md new file mode 100644 index 00000000..54a1b842 --- /dev/null +++ b/tests/databases/README.md @@ -0,0 +1,47 @@ +# Persistence Tests + +Torrust requires Docker to run different database systems for testing. + +Start the databases with `docker-compose` before running tests: + +```s +docker-compose -f tests/databases/docker-compose.yml up +``` + +Run all tests using: + +```s +cargo test +``` + +Connect to the DB using MySQL client: + +```s +mysql -h127.0.0.1 -uroot -ppassword torrust-index_test +``` + +Right now only tests for MySQLite are executed. To run tests for MySQL too, +you have to replace this line in `tests/databases/mysql.rs`: + +```rust + +```rust +#[tokio::test] +#[should_panic] +async fn run_mysql_tests() { + panic!("Todo Test Times Out!"); + #[allow(unreachable_code)] + { + run_tests(DATABASE_URL).await; + } +} +``` + +with this: + +```rust +#[tokio::test] +async fn run_mysql_tests() { + run_tests(DATABASE_URL).await; +} +``` diff --git a/tests/docker-compose.yml b/tests/databases/docker-compose.yml similarity index 100% rename from tests/docker-compose.yml rename to tests/databases/docker-compose.yml