tests for general data pushing
This commit is contained in:
@@ -26,5 +26,31 @@ pub async fn setup_test_db() -> PgPool {
|
||||
.await
|
||||
.expect("Migrations failed");
|
||||
|
||||
// Insert default profile if it doesn't exist
|
||||
let profile = sqlx::query!(
|
||||
r#"
|
||||
INSERT INTO profiles (name)
|
||||
VALUES ('default')
|
||||
ON CONFLICT (name) DO NOTHING
|
||||
RETURNING id
|
||||
"#
|
||||
)
|
||||
.fetch_optional(&pool)
|
||||
.await
|
||||
.expect("Failed to insert test profile");
|
||||
|
||||
let profile_id = if let Some(profile) = profile {
|
||||
profile.id
|
||||
} else {
|
||||
// If the profile already exists, fetch its ID
|
||||
sqlx::query!(
|
||||
"SELECT id FROM profiles WHERE name = 'default'"
|
||||
)
|
||||
.fetch_one(&pool)
|
||||
.await
|
||||
.expect("Failed to fetch default profile ID")
|
||||
.id
|
||||
};
|
||||
|
||||
pool
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user