about summary refs log tree commit diff
path: root/tests/groups.rs
diff options
context:
space:
mode:
authorAlexander_Kabui <alexanderkabua@gmail.com>2026-10-04 08:22:54 +0300
committerAlexander_Kabui <alexanderkabua@gmail.com>2026-10-04 08:22:54 +0300
commit4a2cf5b8cbc95bd973e5e2fc8a331ca98f116df0 (patch)
tree827ec72e34ce5752aa6007eafde3a75171b2df2f /tests/groups.rs
parent6616beba3d6298c49cf2cf77ed63605bf5211168 (diff)
downloadgenenetwork4-4a2cf5b8cbc95bd973e5e2fc8a331ca98f116df0.tar.gz
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.
Diffstat (limited to 'tests/groups.rs')
-rw-r--r--tests/groups.rs11
1 files changed, 4 insertions, 7 deletions
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;
     }