TestDatabaseManager class

Manages the lifecycle and isolation of test databases.

Constructors

TestDatabaseManager({required DataSource baseDataSource, Future<void> runMigrations(DataSource)?, List<Migration>? migrations, List<MigrationDescriptor>? migrationDescriptors, List<DatabaseSeeder Function(OrmConnection)>? seeders, DatabaseIsolationStrategy strategy = DatabaseIsolationStrategy.migrateWithTransactions, DriverAdapter adapterFactory(String testDbName)?, bool parallel = false})

Properties

adapterFactory DriverAdapter Function(String testDbName)?
no setter
baseDataSource DataSource
no setter
hashCode int
The hash code for this object.
no setterinherited
migrationDescriptors List<MigrationDescriptor>?
no setter
migrations List<Migration>?
no setter
runMigrations Future<void> Function(DataSource)?
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
seeders List<DatabaseSeeder Function(OrmConnection)>?
no setter
strategy DatabaseIsolationStrategy
no setter

Methods

cleanup() Future<void>
Cleanup all created test databases
createDatabase(String id) Future<DataSource>
Create a new isolated database for a test group or standalone test
createDataSource(String id) DataSource
Create a DataSource object synchronously without provisioning the DB
dropDatabase(DataSource dataSource) Future<void>
Drop a created database/schema
getSchemaManager(DataSource dataSource) TestSchemaManager?
initialize() Future<void>
Initialize the test database manager
migrate(DataSource dataSource) Future<void>
Run migrations on a specific datasource
migrationStatus(DataSource dataSource) Future<List<MigrationStatus>>
Get migration status
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
provisionDatabase(DataSource dataSource) Future<void>
Provision the database/schema on the server and initialize the DataSource
seed(List<DatabaseSeeder Function(OrmConnection)> seeders, DataSource dataSource) Future<void>
Run seeders on a specific datasource
seedWithPretend(List<DatabaseSeeder Function(OrmConnection)> seeders, DataSource dataSource, {bool pretend = true}) Future<List<QueryLogEntry>>
Preview seeders
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited