From 8eb50412ce5ef93fffd6ae19979402acc46e4c25 Mon Sep 17 00:00:00 2001 From: Eragon Date: Wed, 20 Nov 2024 23:23:03 +0100 Subject: [PATCH] feat: Put MySQL and Sqlite test connexions behind flag --- syncserver-db-common/Cargo.toml | 2 ++ syncserver-db-common/src/test.rs | 9 +++++++-- syncstorage-mysql/Cargo.toml | 2 +- syncstorage-sqlite/Cargo.toml | 10 +++++----- tokenserver-db/Cargo.toml | 2 +- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/syncserver-db-common/Cargo.toml b/syncserver-db-common/Cargo.toml index aba171278e..e2aa55f914 100644 --- a/syncserver-db-common/Cargo.toml +++ b/syncserver-db-common/Cargo.toml @@ -18,3 +18,5 @@ syncserver-common = { path = "../syncserver-common" } [features] sql = [] +mysql = ["sql"] +sqlite = ["sql"] diff --git a/syncserver-db-common/src/test.rs b/syncserver-db-common/src/test.rs index a687bf4ad7..6db3dd0376 100644 --- a/syncserver-db-common/src/test.rs +++ b/syncserver-db-common/src/test.rs @@ -1,19 +1,24 @@ use diesel::{ - mysql::MysqlConnection, r2d2::{CustomizeConnection, Error as PoolError}, - sqlite::SqliteConnection, Connection, }; +#[cfg(feature = "mysql")] +use diesel::mysql::MysqlConnection; +#[cfg(feature = "sqlite")] +use diesel::sqlite::SqliteConnection; + #[derive(Debug)] pub struct TestTransactionCustomizer; +#[cfg(feature = "mysql")] impl CustomizeConnection for TestTransactionCustomizer { fn on_acquire(&self, conn: &mut MysqlConnection) -> Result<(), PoolError> { conn.begin_test_transaction().map_err(PoolError::QueryError) } } +#[cfg(feature = "sqlite")] impl CustomizeConnection for TestTransactionCustomizer { fn on_acquire(&self, conn: &mut SqliteConnection) -> Result<(), PoolError> { conn.begin_test_transaction().map_err(PoolError::QueryError) diff --git a/syncstorage-mysql/Cargo.toml b/syncstorage-mysql/Cargo.toml index 2aa8b99981..659f612d9b 100644 --- a/syncstorage-mysql/Cargo.toml +++ b/syncstorage-mysql/Cargo.toml @@ -18,7 +18,7 @@ diesel = { workspace = true, features = ["mysql", "r2d2"] } diesel_logger = { workspace = true } diesel_migrations = { workspace = true, features = ["mysql"] } syncserver-common = { path = "../syncserver-common" } -syncserver-db-common = { path = "../syncserver-db-common", features = ["sql"] } +syncserver-db-common = { path = "../syncserver-db-common", features = ["mysql"] } syncstorage-db-common = { path = "../syncstorage-db-common" } syncstorage-settings = { path = "../syncstorage-settings" } syncstorage-sql-db-common = { path = "../syncstorage-sql-db-common" } diff --git a/syncstorage-sqlite/Cargo.toml b/syncstorage-sqlite/Cargo.toml index fdd7951495..22a9eccfb6 100644 --- a/syncstorage-sqlite/Cargo.toml +++ b/syncstorage-sqlite/Cargo.toml @@ -11,17 +11,17 @@ base64.workspace=true futures.workspace=true http.workspace=true slog-scope.workspace=true +thiserror.workspace = true +diesel_logger.workspace = true async-trait = "0.1.40" -diesel = { version = "1.4", features = ["sqlite", "r2d2"] } -diesel_logger = "0.1.1" -diesel_migrations = { version = "1.4.0", features = ["sqlite"] } +diesel = { workspace = true, features = ["sqlite", "r2d2"] } +diesel_migrations = { workspace = true, features = ["sqlite"] } syncserver-common = { path = "../syncserver-common" } -syncserver-db-common = { path = "../syncserver-db-common", features = ["sql"] } +syncserver-db-common = { path = "../syncserver-db-common", features = ["sqlite"] } syncstorage-db-common = { path = "../syncstorage-db-common" } syncstorage-settings = { path = "../syncstorage-settings" } syncstorage-sql-db-common = { path = "../syncstorage-sql-db-common" } -thiserror = "1.0.26" url = "2.1" [dev-dependencies] diff --git a/tokenserver-db/Cargo.toml b/tokenserver-db/Cargo.toml index 80d04ee64c..c6b75227b9 100644 --- a/tokenserver-db/Cargo.toml +++ b/tokenserver-db/Cargo.toml @@ -21,7 +21,7 @@ diesel = { workspace = true, features = ["mysql", "r2d2"] } diesel_logger = { workspace = true } diesel_migrations = { workspace = true, features = ["mysql"] } syncserver-common = { path = "../syncserver-common" } -syncserver-db-common = { path = "../syncserver-db-common", features = ["sql"] } +syncserver-db-common = { path = "../syncserver-db-common", features = ["mysql", "sqlite"] } tokenserver-common = { path = "../tokenserver-common" } tokenserver-settings = { path = "../tokenserver-settings" } tokenserver-db-common = { path = "../tokenserver-db-common" }