anvil_test/factory.rs
1//! Model factory pattern. Each app-side factory implements `Factory`.
2
3use async_trait::async_trait;
4
5#[async_trait]
6pub trait Factory: Send + Sync {
7 type Model;
8
9 /// Build an in-memory instance without persisting.
10 fn make(&self) -> Self::Model;
11
12 /// Persist an instance.
13 async fn create(&self, pool: &sqlx::PgPool) -> Result<Self::Model, sqlx::Error>;
14}