pub trait TestSupport: Database {
    // Required methods
    fn test_context(
        args: &TestArgs
    ) -> BoxFuture<'_, Result<TestContext<Self>, Error>>;
    fn cleanup_test(db_name: &str) -> BoxFuture<'_, Result<(), Error>>;
    fn cleanup_test_dbs() -> BoxFuture<'static, Result<Option<usize>, Error>>;
    fn snapshot(
        conn: &mut Self::Connection
    ) -> BoxFuture<'_, Result<FixtureSnapshot<Self>, Error>>;
}

Required Methods§

source

fn test_context( args: &TestArgs ) -> BoxFuture<'_, Result<TestContext<Self>, Error>>

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.

source

fn cleanup_test(db_name: &str) -> BoxFuture<'_, Result<(), Error>>

source

fn cleanup_test_dbs() -> BoxFuture<'static, Result<Option<usize>, Error>>

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.

source

fn snapshot( conn: &mut Self::Connection ) -> BoxFuture<'_, Result<FixtureSnapshot<Self>, Error>>

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.

Implementors§