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/groups.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'tests/groups.rs') diff --git a/tests/groups.rs b/tests/groups.rs index 3966ac4..d9aba36 100644 --- a/tests/groups.rs +++ b/tests/groups.rs @@ -4,19 +4,16 @@ use http_body_util::BodyExt; use serde_json::Value; use tower::ServiceExt; +mod common; + /// Needs a live MariaDB connection (SQL_URI, see src/db.rs); skips rather /// than fails when none is reachable, same as species.rs. BXD is used /// everywhere as a test fixture in the GeneNetwork2/GeneNetwork3 test /// suites and is always present in the database. #[tokio::test] async fn groups_returns_ok_with_bxd() { - if std::net::TcpStream::connect_timeout( - &"127.0.0.1:3306".parse().unwrap(), - std::time::Duration::from_millis(500), - ) - .is_err() - { - eprintln!("skipping groups_returns_ok_with_bxd: no database on 127.0.0.1:3306"); + if !common::db_available() { + eprintln!("skipping groups_returns_ok_with_bxd: no usable database (check SQL_URI credentials)"); return; } -- cgit 1.4.1