Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions crates/trapfalld/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,11 @@ mod tests {
assert!(cfg.max_ingest_body_bytes < cfg.max_body_bytes, "ingest limit must be tighter than general API limit");
}

/// Serializes tests that mutate `TRAPFALL_RETENTION_DAYS`: cargo runs
/// tests on parallel threads and env vars are process-global, so two
/// tests touching the same var race and fail intermittently.
static RETENTION_ENV_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(());

#[test]
fn retention_days_default() {
assert_eq!(default_retention_days(), 90);
Expand All @@ -407,7 +412,7 @@ mod tests {

#[test]
fn retention_days_custom_env() {
// SAFETY: single-threaded test, no other code reads this env var concurrently.
let _guard = RETENTION_ENV_LOCK.lock().unwrap_or_else(|p| p.into_inner());
unsafe {
std::env::set_var("TRAPFALL_RETENTION_DAYS", "30");
}
Expand All @@ -419,7 +424,7 @@ mod tests {

#[test]
fn retention_days_invalid_falls_back() {
// SAFETY: single-threaded test, no other code reads this env var concurrently.
let _guard = RETENTION_ENV_LOCK.lock().unwrap_or_else(|p| p.into_inner());
unsafe {
std::env::set_var("TRAPFALL_RETENTION_DAYS", "abc");
}
Expand Down
Loading