From 4a2cf5b8cbc95bd973e5e2fc8a331ca98f116df0 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Sun, 4 Oct 2026 08:22:54 +0300 Subject: Fix DB tests: probe SQL_URI credentials, not just the port The old skip check connected to 127.0.0.1:3306, so tests ran (and failed with 500) whenever a server was listening but the configured credentials were rejected. tests/common/mod.rs now attempts a real connection with the configured SQL_URI; tests skip only when the database is genuinely unusable, and run for real otherwise. --- tests/common/mod.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tests/common/mod.rs (limited to 'tests/common') diff --git a/tests/common/mod.rs b/tests/common/mod.rs new file mode 100644 index 0000000..dcee085 --- /dev/null +++ b/tests/common/mod.rs @@ -0,0 +1,14 @@ +//! Shared helpers for integration tests. + +/// True only when the database in `SQL_URI` actually accepts the +/// configured credentials. Tests that need a live MariaDB skip (rather +/// than fail) when this is false — a server may be listening on the +/// port yet still be unusable (wrong credentials), which a plain port +/// check cannot see. +pub fn db_available() -> bool { + let config = genenetwork4::config::Config::load(); + let Ok(opts) = mysql::Opts::from_url(&config.sql_uri) else { + return false; + }; + mysql::Conn::new(opts).is_ok() +} -- cgit 1.4.1