Skip to content

Commit 3dd38a7

Browse files
authored
fix(tests): Synchronize all figment tests (#174)
Fixes a flaky test where the environment variables from other tests leaked into `configurable_via_yaml`. This is because `figment::Jail` is not actually sandboxed but rather synchronizes all calls to avoid env races.
1 parent 0ed8660 commit 3dd38a7

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

objectstore-server/src/config.rs

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -354,25 +354,30 @@ mod tests {
354354
)
355355
.unwrap();
356356

357-
let args = Args {
358-
config: Some(tempfile.path().into()),
359-
};
360-
let config = Config::from_args(args).unwrap();
357+
figment::Jail::expect_with(|_jail| {
358+
let args = Args {
359+
config: Some(tempfile.path().into()),
360+
};
361+
let config = Config::from_args(args).unwrap();
361362

362-
let Storage::S3Compatible { endpoint, bucket } = &dbg!(&config).long_term_storage else {
363-
panic!("expected s3 storage");
364-
};
365-
assert_eq!(endpoint, "http://localhost:8888");
366-
assert_eq!(bucket, "whatever");
367-
368-
assert_eq!(config.sentry.dsn.unwrap().expose_secret().as_str(), "abcde");
369-
assert_eq!(config.sentry.environment.as_deref(), Some("production"));
370-
assert_eq!(
371-
config.sentry.server_name.as_deref(),
372-
Some("objectstore-deadbeef")
373-
);
374-
assert_eq!(config.sentry.sample_rate, 0.5);
375-
assert_eq!(config.sentry.traces_sample_rate, 0.5);
363+
let Storage::S3Compatible { endpoint, bucket } = &dbg!(&config).long_term_storage
364+
else {
365+
panic!("expected s3 storage");
366+
};
367+
assert_eq!(endpoint, "http://localhost:8888");
368+
assert_eq!(bucket, "whatever");
369+
370+
assert_eq!(config.sentry.dsn.unwrap().expose_secret().as_str(), "abcde");
371+
assert_eq!(config.sentry.environment.as_deref(), Some("production"));
372+
assert_eq!(
373+
config.sentry.server_name.as_deref(),
374+
Some("objectstore-deadbeef")
375+
);
376+
assert_eq!(config.sentry.sample_rate, 0.5);
377+
assert_eq!(config.sentry.traces_sample_rate, 0.5);
378+
379+
Ok(())
380+
});
376381
}
377382

378383
#[test]
@@ -388,6 +393,7 @@ mod tests {
388393
"#,
389394
)
390395
.unwrap();
396+
391397
figment::Jail::expect_with(|jail| {
392398
jail.set_env("fss_long_term_storage__endpoint", "http://localhost:9001");
393399

0 commit comments

Comments
 (0)