diff options
| author | Alexander_Kabui <alexanderkabua@gmail.com> | 2026-10-04 08:22:54 +0300 |
|---|---|---|
| committer | Alexander_Kabui <alexanderkabua@gmail.com> | 2026-10-04 08:22:54 +0300 |
| commit | 4a2cf5b8cbc95bd973e5e2fc8a331ca98f116df0 (patch) | |
| tree | 827ec72e34ce5752aa6007eafde3a75171b2df2f /tests/common | |
| parent | 6616beba3d6298c49cf2cf77ed63605bf5211168 (diff) | |
| download | genenetwork4-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/common')
| -rw-r--r-- | tests/common/mod.rs | 14 |
1 files changed, 14 insertions, 0 deletions
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() +} |
