Skip to main content

test

Attribute Macro test 

Source
#[test]
Expand description

Attribute macro for database-backed tests.

Creates a temporary database, optionally runs migrations, provides a Client argument, and drops the database after the test completes.

#[resolute::test]
async fn my_test(client: resolute::Client) {
    client.simple_query("CREATE TABLE t (id int)").await.unwrap();
    client.execute("INSERT INTO t VALUES ($1)", &[&1i32]).await.unwrap();
}

#[resolute::test(migrations = "migrations")]
async fn with_migrations(client: resolute::Client) {
    // migrations have already been applied
}