pub fn assert_migration<F>(self, name_matcher: &str, assertions: F) -> AssertionResult<Self>
    where
        F: for<'b> FnOnce(MigrationAssertion<'b>) -> AssertionResult<MigrationAssertion<'b>>,
    {
        let migration = std::fs::read_dir(self.migrations_directory.path())
            .context("Reading migrations directory for named migration.")?
            .find_map(|entry| {
                let entry = entry.unwrap();
                let name = entry.file_name();

                if name.to_str().unwrap().contains(name_matcher) {
                    Some(entry)
                } else {
                    None
                }
            });

        match migration {
            Some(migration) => {
                let path = migration.path();
                let assertion = MigrationAssertion { path: path.as_ref() };

                assertions(assertion)?;
            }
            None => anyhow::bail!(
                "Assertion error. Could not find migration with name matching `{}`",
                name_matcher
            ),
        }

        Ok(self)
    }
/// Assert that there is one migration with `name_matcher` contained in its name present in the migration directory.
Assert that there is one migration with `name_matcher` contained in its name present in the migration directory.
Assert that there is one migration with ` name_matcher ` contained in its name present in the migration directory .
pub fn assert_migration<F>(self, name_matcher: &str, assertions: F) -> AssertionResult<Self>
    where
        F: for<'b> FnOnce(MigrationAssertion<'b>) -> AssertionResult<MigrationAssertion<'b>>,
    {
        let migration = std::fs::read_dir(self.migrations_directory.path())
            .context("Reading migrations directory for named migration.")?
            .find_map(|entry| {
                let entry = entry.unwrap();
                let name = entry.file_name();
                if name.to_str().unwrap().contains(name_matcher) {
                    Some(entry)
                } else {
                    None
                }
            });
        match migration {
            Some(migration) => {
                let path = migration.path();
                let assertion = MigrationAssertion { path: path.as_ref() };
                assertions(assertion)?;
            }
            None => anyhow::bail!(
                "Assertion error. Could not find migration with name matching `{}`",
                name_matcher
            ),
        }
        Ok(self)
    }
pub fn assert_migration < F > ( self , name_matcher : & str , assertions : F ) -> AssertionResult < Self > where F : for < ' b > FnOnce ( MigrationAssertion < ' b > ) -> AssertionResult < MigrationAssertion < ' b > > , { let migration = std :: fs :: read_dir ( self . migrations_directory . path ( ) ) . context ( " " ) ? . find_map ( | entry | { let entry = entry . unwrap ( ) ; let name = entry . file_name ( ) ; if name . to_str ( ) . unwrap ( ) . contains ( name_matcher ) { Some ( entry ) } else { None } } ) ; match migration { Some ( migration ) => { let path = migration . path ( ) ; let assertion = MigrationAssertion { path : path . as_ref ( ) } ; assertions ( assertion ) ? ; } None => anyhow :: bail ! ( " " name_matcher ) , } Ok ( self ) }
Assert that there is one migration with `name_matcher` contained in its name present in the migration directory.
Assert that there is one migration with ` name_matcher ` contained in its name present in the migration directory .
self
name_matcher
&str
assertions
F
self
name_matcher
&str
assertions
F