Parcourir la source

Fix tests for sqlcipher

Cesar Rodas il y a 4 mois
Parent
commit
032d6e66bc
2 fichiers modifiés avec 11 ajouts et 2 suppressions
  1. 1 1
      crates/cdk-sqlite/src/common.rs
  2. 10 1
      crates/cdk-sqlite/src/mint/mod.rs

+ 1 - 1
crates/cdk-sqlite/src/common.rs

@@ -107,7 +107,7 @@ pub fn migrate(conn: &mut Connection, migrations: &[(&str, &str)]) -> Result<(),
             r#"
         INSERT INTO migrations
         SELECT
-            concat(version, '_', REPLACE(description, ' ', '_'), '.sql'),
+            version || '_' ||  REPLACE(description, ' ', '_') || '.sql',
             execution_time
         FROM _sqlx_migrations;
         DROP TABLE _sqlx_migrations;

+ 10 - 1
crates/cdk-sqlite/src/mint/mod.rs

@@ -1532,13 +1532,22 @@ mod tests {
 
         {
             let _ = remove_file(&file);
+            #[cfg(not(feature = "sqlcipher"))]
             let legacy = create_sqlite_pool(&file);
+            #[cfg(feature = "sqlcipher")]
+            let legacy = create_sqlite_pool(&file, "test".to_owned());
             let y = legacy.get().expect("pool");
             y.execute_batch(include_str!("../../tests/legacy-sqlx.sql"))
                 .expect("create former db failed");
         }
 
-        assert!(MintSqliteDatabase::new(&file).await.is_ok());
+        #[cfg(not(feature = "sqlcipher"))]
+        let conn = MintSqliteDatabase::new(&file).await;
+
+        #[cfg(feature = "sqlcipher")]
+        let conn = MintSqliteDatabase::new(&file, "test".to_owned()).await;
+
+        assert!(conn.is_ok(), "Failed with {:?}", conn.unwrap_err());
 
         let _ = remove_file(&file);
     }