Skip to content

Commit bb3a83e

Browse files
author
Davide Melfi
committed
chore: fix another test
1 parent cf364d1 commit bb3a83e

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

lambda-runtime/src/layers/api_client.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,12 @@ mod tests {
204204
#[tokio::test]
205205
async fn test_non_2xx_logs_status_and_body() {
206206
let storage = SharedStorage::default();
207-
// try_init is used here intentionally: multiple tests may run concurrently and attempt
208-
// to set a global subscriber. We use try_init().ok() to tolerate that gracefully.
209-
// The find() below filters specifically for the 410 event so stale events from other
210-
// tests don't cause false positives.
211-
tracing_subscriber::registry()
207+
// Use set_default (thread-local) so we don't race with other tests that call
208+
// set_global_default. #[tokio::test] uses a single-threaded executor, so the
209+
// guard remains valid for the entire test body.
210+
let _guard = tracing_subscriber::registry()
212211
.with(CaptureLayer::new(&storage))
213-
.try_init()
214-
.ok();
212+
.set_default();
215213

216214
let server = MockServer::start();
217215

0 commit comments

Comments
 (0)