From 21dd0d4c12362994fa85620302831faa6b2febcb Mon Sep 17 00:00:00 2001 From: Alex Helfet Date: Sat, 6 Jul 2024 00:29:29 +0100 Subject: [PATCH] Make fn `Migrations::max_schema_version` public. --- rusqlite_migration/src/lib.rs | 2 +- rusqlite_migration/src/tests/synch.rs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/rusqlite_migration/src/lib.rs b/rusqlite_migration/src/lib.rs index 5ba4da9..085820c 100644 --- a/rusqlite_migration/src/lib.rs +++ b/rusqlite_migration/src/lib.rs @@ -601,7 +601,7 @@ impl<'m> Migrations<'m> { } /// Maximum version defined in the migration set - fn max_schema_version(&self) -> SchemaVersion { + pub fn max_schema_version(&self) -> SchemaVersion { match self.ms.len() { 0 => SchemaVersion::NoneSet, v => SchemaVersion::Inside( diff --git a/rusqlite_migration/src/tests/synch.rs b/rusqlite_migration/src/tests/synch.rs index f57cd8b..d5eaab5 100644 --- a/rusqlite_migration/src/tests/synch.rs +++ b/rusqlite_migration/src/tests/synch.rs @@ -270,6 +270,10 @@ fn user_version_migrate_test() { Ok(SchemaVersion::Inside(NonZeroUsize::new(1).unwrap())), migrations.current_version(&conn) ); + assert_eq!( + SchemaVersion::Inside(NonZeroUsize::new(1).unwrap()), + migrations.max_schema_version() + ); let migrations = Migrations::new(vec![m_valid10(), m_valid11()]); assert_eq!(Ok(()), migrations.to_latest(&mut conn)); @@ -278,6 +282,10 @@ fn user_version_migrate_test() { Ok(SchemaVersion::Inside(NonZeroUsize::new(2).unwrap())), migrations.current_version(&conn) ); + assert_eq!( + SchemaVersion::Inside(NonZeroUsize::new(2).unwrap()), + migrations.max_schema_version() + ); } #[test]