Trait sfo_sql::testing::TestSupport
source · pub trait TestSupport: Database {
// Required methods
fn test_context(
args: &TestArgs,
) -> Pin<Box<dyn Future<Output = Result<TestContext<Self>, Error>> + Send + '_>>;
fn cleanup_test(
db_name: &str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + '_>>;
fn cleanup_test_dbs( ) -> Pin<Box<dyn Future<Output = Result<Option<usize>, Error>> + Send>>;
fn snapshot(
conn: &mut Self::Connection,
) -> Pin<Box<dyn Future<Output = Result<FixtureSnapshot<Self>, Error>> + Send + '_>>;
}
Required Methods§
sourcefn test_context(
args: &TestArgs,
) -> Pin<Box<dyn Future<Output = Result<TestContext<Self>, Error>> + Send + '_>>
fn test_context( args: &TestArgs, ) -> Pin<Box<dyn Future<Output = Result<TestContext<Self>, Error>> + Send + '_>>
Get parameters to construct a Pool
suitable for testing.
This Pool
instance will behave somewhat specially:
- all handles share a single global semaphore to avoid exceeding the connection limit on the database server.
- each invocation results in a different temporary database.
The implementation may require DATABASE_URL
to be set in order to manage databases.
The user credentials it contains must have the privilege to create and drop databases.
fn cleanup_test( db_name: &str, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + '_>>
sourcefn cleanup_test_dbs() -> Pin<Box<dyn Future<Output = Result<Option<usize>, Error>> + Send>>
fn cleanup_test_dbs() -> Pin<Box<dyn Future<Output = Result<Option<usize>, Error>> + Send>>
Cleanup any test databases that are no longer in-use.
Returns a count of the databases deleted, if possible.
The implementation may require DATABASE_URL
to be set in order to manage databases.
The user credentials it contains must have the privilege to create and drop databases.
sourcefn snapshot(
conn: &mut Self::Connection,
) -> Pin<Box<dyn Future<Output = Result<FixtureSnapshot<Self>, Error>> + Send + '_>>
fn snapshot( conn: &mut Self::Connection, ) -> Pin<Box<dyn Future<Output = Result<FixtureSnapshot<Self>, Error>> + Send + '_>>
Take a snapshot of the current state of the database (data only).
This snapshot can then be used to generate test fixtures.
Object Safety§
This trait is not object safe.