Skip to content

Commit

Permalink
fix: uses NamedTempFile for inline test pathing
Browse files Browse the repository at this point in the history
  • Loading branch information
tuddman committed Apr 4, 2024
1 parent 84041df commit 98e7776
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,18 @@ async fn upload_file(

// Create a new UUID for the file.
let file_id = Uuid::new_v4();
let file_name = format!("uploads/{}", file_id);
let file_name: String;

#[cfg(not(test))]
{
file_name = format!("uploads/{}", file_id)
}

#[cfg(test)]
{
use tempfile::NamedTempFile;
file_name = NamedTempFile::new().unwrap().path().to_string_lossy().to_string();
}

// Try to create the file.
let mut file = match File::create(&file_name) {
Expand Down

0 comments on commit 98e7776

Please sign in to comment.