Skip to main content

test_database

Macro test_database 

Source
macro_rules! test_database {
    () => { ... };
    ($migrator:ty) => { ... };
}
Expand description

Create a test database with default migrator

This macro creates a TestDatabase using crate::migrations::Migrator as the default migrator. This follows the Ferro convention where migrations are defined in src/migrations/mod.rs.

§Example

use ferro_rs::test_database;

#[tokio::test]
async fn test_user_creation() {
    let db = test_database!();

    let action = CreateUserAction::new();
    let user = action.execute("test@example.com").await.unwrap();
    assert!(user.id > 0);
}

§With Custom Migrator

let db = test_database!(my_crate::CustomMigrator);