diff options
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() +} |
