mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2025-12-11 20:15:30 +01:00
- Refactored `remove_emojis.sh` to enhance the emoji removal process by using a more efficient Python script for detecting and removing 3D/colorful emojis followed by spaces. - Updated various Rust files to remove emoji characters from log messages and print statements, resulting in a cleaner output. - Improved user experience with color-coded progress and results during the emoji removal process. - Ensured that the script counts processed files and reports modifications accurately.
64 lines
1.5 KiB
Rust
64 lines
1.5 KiB
Rust
//! Test database migration functionality
|
|
|
|
use sd_core::infra::db::Database;
|
|
use tempfile::TempDir;
|
|
|
|
#[tokio::test]
|
|
async fn test_database_creation_and_migration() {
|
|
// Create a temporary directory for the test database
|
|
let temp_dir = TempDir::new().unwrap();
|
|
let db_path = temp_dir.path().join("test.db");
|
|
|
|
println!("Creating database at: {:?}", db_path);
|
|
|
|
// Create the database
|
|
let db = Database::create(&db_path)
|
|
.await
|
|
.expect("Failed to create database");
|
|
|
|
println!("Database created successfully, running migrations...");
|
|
|
|
// Run migrations with debug info
|
|
println!("Running migrations...");
|
|
let result = db.migrate().await;
|
|
|
|
match result {
|
|
Ok(()) => {
|
|
println!("Migrations completed successfully!");
|
|
}
|
|
Err(e) => {
|
|
println!("Migration failed: {}", e);
|
|
panic!("Migration failed: {}", e);
|
|
}
|
|
}
|
|
|
|
// Verify the database exists and has tables
|
|
assert!(db_path.exists(), "Database file should exist");
|
|
|
|
// Try to connect to verify it's a valid database
|
|
let conn = db.conn();
|
|
|
|
// Try a simple query to verify the database is working
|
|
use sea_orm::{ConnectionTrait, Statement};
|
|
|
|
let result = conn
|
|
.execute(Statement::from_string(
|
|
sea_orm::DatabaseBackend::Sqlite,
|
|
"SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;".to_string(),
|
|
))
|
|
.await;
|
|
|
|
match result {
|
|
Ok(result) => {
|
|
println!(
|
|
"Database query successful, {} rows affected",
|
|
result.rows_affected()
|
|
);
|
|
}
|
|
Err(e) => {
|
|
println!("Database query failed: {}", e);
|
|
panic!("Database query failed: {}", e);
|
|
}
|
|
}
|
|
}
|