#[cfg(feature = "testing")]
use std::env;
#[cfg(feature = "testing")]
use std::sync::LazyLock;
#[cfg(feature = "testing")]
pub(crate) const SWITCH: &str = "RUSTSTREAM_SQLX_OUTBOX";
#[cfg(not(feature = "testing"))]
#[inline]
pub(crate) const fn enabled() -> bool {
true
}
#[cfg(feature = "testing")]
pub(crate) fn enabled() -> bool {
static ON: LazyLock<bool> = LazyLock::new(|| reads_on(env::var(SWITCH).ok().as_deref()));
*ON
}
#[cfg(any(feature = "testing", test))]
fn reads_on(value: Option<&str>) -> bool {
value == Some("on")
}
#[cfg(test)]
mod tests {
use super::reads_on;
#[test]
fn only_on_turns_the_outbox_on() {
assert!(reads_on(Some("on")));
assert!(!reads_on(None));
assert!(!reads_on(Some("")));
assert!(!reads_on(Some("1")));
assert!(!reads_on(Some("ON")));
}
}