()
| 245 | |
| 246 | #[test] |
| 247 | fn test_drift_report_formatting() -> rusqlite::Result<()> { |
| 248 | let mut conn = Connection::open_in_memory()?; |
| 249 | |
| 250 | // Initialize metadata table |
| 251 | TypeMetadata::init(&conn)?; |
| 252 | |
| 253 | // Create a table with drift |
| 254 | conn.execute( |
| 255 | "CREATE TABLE users ( |
| 256 | id INTEGER PRIMARY KEY, |
| 257 | name TEXT |
| 258 | )", |
| 259 | [] |
| 260 | )?; |
| 261 | |
| 262 | // Store metadata with drift |
| 263 | let tx = conn.transaction()?; |
| 264 | tx.execute( |
| 265 | "INSERT INTO __pgsqlite_schema (table_name, column_name, pg_type, sqlite_type) |
| 266 | VALUES |
| 267 | ('users', 'id', 'int4', 'INTEGER'), |
| 268 | ('users', 'name', 'int4', 'INTEGER'), |
| 269 | ('users', 'email', 'text', 'TEXT')", |
| 270 | [] |
| 271 | )?; |
| 272 | tx.commit()?; |
| 273 | |
| 274 | // Check report format |
| 275 | let drift = SchemaDriftDetector::detect_drift(&conn).unwrap(); |
| 276 | let report = drift.format_report(); |
| 277 | |
| 278 | assert!(report.contains("Table 'users' has schema drift")); |
| 279 | assert!(report.contains("Columns in metadata but missing from SQLite")); |
| 280 | assert!(report.contains("email (text)")); |
| 281 | assert!(report.contains("Type mismatches")); |
| 282 | assert!(report.contains("name expected SQLite type 'INTEGER' but found 'TEXT'")); |
| 283 | |
| 284 | Ok(()) |
| 285 | } |
| 286 | |
| 287 | #[test] |
| 288 | fn test_type_normalization() -> rusqlite::Result<()> { |
nothing calls this directly
no test coverage detected