Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp

fix(app-proxy): give each test fixture its own temp directory (#2261)

Hampus09cea4394ff2
diff --git a/fluxer_app_proxy/src/routes/assets_proxy.rs b/fluxer_app_proxy/src/routes/assets_proxy.rs
index b2ea91856..27e126649 100644
--- a/fluxer_app_proxy/src/routes/assets_proxy.rs
+++ b/fluxer_app_proxy/src/routes/assets_proxy.rs
@@ -380,6 +380,7 @@ mod tests {
use fluxer_common::config::GeoipSourceConfig;
use fluxer_common::geoip::{GeoipConfig, GeoipResolver};
use std::sync::Arc;
+ use std::sync::atomic::{AtomicU64, Ordering};
use tower::ServiceExt;
async fn spawn_upstream(status: StatusCode, cache_control: &'static str) -> String {
@@ -629,11 +630,11 @@ mod tests {
impl LocalAssetDir {
fn with_asset(name: &str, bytes: &[u8]) -> Self {
- let unique = std::time::SystemTime::now()
- .duration_since(std::time::UNIX_EPOCH)
- .unwrap()
- .as_nanos();
- let root = std::env::temp_dir().join(format!("fluxer-local-asset-{unique}-{name}"));
+ static NEXT_FIXTURE: AtomicU64 = AtomicU64::new(0);
+ let unique = NEXT_FIXTURE.fetch_add(1, Ordering::Relaxed);
+ let pid = std::process::id();
+ let root =
+ std::env::temp_dir().join(format!("fluxer-local-asset-{pid}-{unique}-{name}"));
std::fs::create_dir_all(root.join("assets")).unwrap();
std::fs::write(root.join("assets").join(name), bytes).unwrap();
Self { root }
diff --git a/fluxer_app_proxy/src/routes/file_stream.rs b/fluxer_app_proxy/src/routes/file_stream.rs
index 4515a5a39..6c5b6441d 100644
--- a/fluxer_app_proxy/src/routes/file_stream.rs
+++ b/fluxer_app_proxy/src/routes/file_stream.rs
@@ -156,6 +156,7 @@ fn parse_byte_range(raw: &str, file_size: u64) -> RequestedRange {
#[cfg(test)]
mod tests {
use super::*;
+ use std::sync::atomic::{AtomicU64, Ordering};
struct StreamedFile {
root: std::path::PathBuf,
@@ -163,11 +164,10 @@ mod tests {
impl StreamedFile {
fn with_bytes(bytes: &[u8]) -> Self {
- let unique = std::time::SystemTime::now()
- .duration_since(std::time::UNIX_EPOCH)
- .unwrap()
- .as_nanos();
- let root = std::env::temp_dir().join(format!("fluxer-file-stream-{unique}"));
+ static NEXT_FIXTURE: AtomicU64 = AtomicU64::new(0);
+ let unique = NEXT_FIXTURE.fetch_add(1, Ordering::Relaxed);
+ let pid = std::process::id();
+ let root = std::env::temp_dir().join(format!("fluxer-file-stream-{pid}-{unique}"));
std::fs::create_dir_all(&root).unwrap();
std::fs::write(root.join("payload.bin"), bytes).unwrap();
Self { root }