pub struct TestMigrationSource { /* private fields */ }Expand description
In-memory migration source for testing
Provides a simple implementation of MigrationSource that stores migrations
in memory. Useful for testing migration-related functionality without
filesystem or database dependencies.
§Examples
// #[tokio::test]
// async fn test_source() {
let mut source = TestMigrationSource::new();
source.add_migration(Migration::new("0001_initial", "polls"));
let migrations = source.all_migrations().await.unwrap();
assert_eq!(migrations.len(), 1);
// }Implementations§
Source§impl TestMigrationSource
impl TestMigrationSource
Sourcepub fn with_migrations(migrations: Vec<Migration>) -> Self
pub fn with_migrations(migrations: Vec<Migration>) -> Self
Create a TestMigrationSource with initial migrations
Sourcepub fn add_migration(&mut self, migration: Migration)
pub fn add_migration(&mut self, migration: Migration)
Add a migration to the source
Trait Implementations§
Source§impl Default for TestMigrationSource
impl Default for TestMigrationSource
Source§impl MigrationSource for TestMigrationSource
impl MigrationSource for TestMigrationSource
Source§fn all_migrations<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Migration>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn all_migrations<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Migration>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns all migrations from this source
Source§fn migrations_for_app<'life0, 'life1, 'async_trait>(
&'life0 self,
app_label: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Migration>, MigrationError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn migrations_for_app<'life0, 'life1, 'async_trait>(
&'life0 self,
app_label: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Migration>, MigrationError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Returns migrations for a specific app
Source§fn get_migration<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
app_label: &'life1 str,
name: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Migration, MigrationError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn get_migration<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
app_label: &'life1 str,
name: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Migration, MigrationError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Returns a specific migration by app and name
Auto Trait Implementations§
impl Freeze for TestMigrationSource
impl RefUnwindSafe for TestMigrationSource
impl Send for TestMigrationSource
impl Sync for TestMigrationSource
impl Unpin for TestMigrationSource
impl UnsafeUnpin for TestMigrationSource
impl UnwindSafe for TestMigrationSource
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().