#![cfg(feature = "profiling-bridge-pyroscope-rs")]
#[tokio::test]
async fn profiler_creation_fails_without_a_writable_temp_dir() {
unsafe {
std::env::set_var("TMPDIR", "/nonexistent-directory-simulating-scratch-image");
}
let result = otel_bootstrap::Telemetry::builder("test-svc-no-tmp")
.with_profiling("http://127.0.0.1:4040")
.init();
let Err(err) = result else {
panic!(
"expected profiler creation to fail without a writable temp dir \
(this is the exact 'create profiler error' that crash-looped \
brefwiz-spiffe-server's main container in production), got Ok"
);
};
let msg = err.to_string();
assert!(
msg.contains("profiler"),
"expected the profiler-creation error to surface, got: {msg}"
);
}