ruma / homeserver

A Matrix homeserver written in Rust.
https://www.ruma.io/
1.08k stars 41 forks source link

Create test database and run migrations from Rust #67

Open jimmycuadra opened 8 years ago

jimmycuadra commented 8 years ago

I'd like to support a workflow where Ruma can be developed with only Docker Compose, not requiring Postgres, diesel-cli, or even Rust to be installed on the host computer.

Right now the procedure for running the test suite looks like this:

  1. cargo test --no-run to make sure there are no compilation errors before starting the heavy machinery.
  2. Start the test database in a Docker container.
  3. Run diesel-cli's commands to create the database and run the migrations.
  4. cargo test

A better flow would be to have the test code itself manage the creation (or drop and recreation) of the test database and migrations. Then everything could be wired up with Docker Compose and there could be a script that did something like docker-compose run --rm cargo test, which would start a dependent "postgres" service, but not require any external tooling to manage stuff.

jimmycuadra commented 8 years ago

In order to do this nicely, it'll be necessary for diesel_cli's database setup functionality to be exposed via a Rust API. See https://github.com/diesel-rs/diesel/issues/357

jimmycuadra commented 8 years ago

This is done, but I'm gonna leave this issue open so that the internals of the test module can be cleaned up a bit in the event that diesel_cli adds a public API as mentioned in the comment above.