Add RabbitMQ validation, test scaffolding, and config refactor
- Extract ipl() from main() with env-aware error handling (fatal in prod, warn in dev) - Add amqp::validate() — TCP reachability check for RabbitMQ at IPL - Refactor config::load() into load() + load_from() for testability - Add lib.rs to expose public API to integration test harness - Add test fixture scaffolding: tests/fixtures/beds_test.toml, tests/common/mod.rs - Add unit tests for amqp::validate() error paths (closed port, bad address) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
39
tests/common/mod.rs
Normal file
39
tests/common/mod.rs
Normal file
@@ -0,0 +1,39 @@
|
||||
//! # tests/common/mod.rs — Shared Test Helpers
|
||||
//!
|
||||
//! Provides shared fixtures and helper functions for all BEDS integration
|
||||
//! tests. Unit tests within source files use the same fixture path directly
|
||||
//! via `config::load_from()`.
|
||||
//!
|
||||
//! ## Usage
|
||||
//!
|
||||
//! In any integration test file under `tests/`:
|
||||
//! ```
|
||||
//! mod common;
|
||||
//! let cfg = common::load_test_config();
|
||||
//! ```
|
||||
//!
|
||||
//! **Author:** mks
|
||||
//! **Version:** 1.0
|
||||
//!
|
||||
//! ## History
|
||||
//! * `2026-04-02` - mks - original coding
|
||||
|
||||
/// Path to the canonical test config fixture, relative to the workspace root.
|
||||
pub const TEST_CONFIG_PATH: &str = "tests/fixtures/beds_test.toml";
|
||||
|
||||
/// Loads the canonical BEDS test configuration fixture.
|
||||
///
|
||||
/// Panics on failure — a missing or malformed test fixture is a broken test
|
||||
/// environment, not a recoverable error.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// A fully-deserialised `BedsConfig` from `tests/fixtures/beds_test.toml`.
|
||||
///
|
||||
/// # History
|
||||
///
|
||||
/// * `2026-04-02` - mks - original coding
|
||||
pub fn load_test_config() -> rustybeds::config::BedsConfig {
|
||||
rustybeds::config::load_from(TEST_CONFIG_PATH, "")
|
||||
.expect("test fixture beds_test.toml failed to load")
|
||||
}
|
||||
Reference in New Issue
Block a user