| 1 | #![cfg(unix)] |
| 2 | use sqlx::migrate::Migrator; |
| 3 | use std::path::Path; |
| 4 | |
| 5 | static EMBEDDED_SIMPLE: Migrator = sqlx::migrate!("tests/migrate/migrations_simple"); |
| 6 | static EMBEDDED_REVERSIBLE: Migrator = sqlx::migrate!("tests/migrate/migrations_reversible"); |
| 7 | static EMBEDDED_SYMLINK: Migrator = sqlx::migrate!("tests/migrate/migrations_symlink"); |
| 8 | |
| 9 | #[sqlx_macros::test] |
| 10 | async fn same_output() -> anyhow::Result<()> { |
| 11 | let runtime_simple = Migrator::new(Path::new("tests/migrate/migrations_simple")).await?; |
| 12 | let runtime_reversible = |
| 13 | Migrator::new(Path::new("tests/migrate/migrations_reversible")).await?; |
| 14 | let runtime_symlink = Migrator::new(Path::new("tests/migrate/migrations_symlink")).await?; |
| 15 | |
| 16 | assert_same(&EMBEDDED_SIMPLE, &runtime_simple); |
| 17 | assert_same(&EMBEDDED_REVERSIBLE, &runtime_reversible); |
| 18 | assert_same(&EMBEDDED_SYMLINK, &runtime_symlink); |
| 19 | |
| 20 | Ok(()) |
| 21 | } |
| 22 | |
| 23 | fn assert_same(embedded: &Migrator, runtime: &Migrator) { |
| 24 | assert_eq!(runtime.migrations.len(), embedded.migrations.len()); |
| 25 | |
| 26 | for (e, r) in embedded.iter().zip(runtime.iter()) { |
| 27 | assert_eq!(e.version, r.version); |
| 28 | assert_eq!(e.description, r.description); |
| 29 | assert_eq!(e.migration_type, r.migration_type); |
| 30 | assert_eq!(e.sql, r.sql); |
| 31 | assert_eq!(e.checksum, r.checksum); |
| 32 | } |
| 33 | } |