Skip to content

Commit

Permalink
Remove trailing newline from extensionless precompressed test files
Browse files Browse the repository at this point in the history
  • Loading branch information
SvizelPritula committed Sep 19, 2024
1 parent 531ee68 commit 7dedf26
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion test-files/extensionless_precompressed
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Content.
Content.
Binary file modified test-files/extensionless_precompressed.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion test-files/extensionless_precompressed_missing
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Content.
Content.
9 changes: 7 additions & 2 deletions tower-http/src/services/fs/serve_dir/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use http::{Request, StatusCode};
use http_body::Body as HttpBody;
use http_body_util::BodyExt;
use std::convert::Infallible;
use std::fs;
use std::io::Read;
use tower::{service_fn, ServiceExt};

Expand Down Expand Up @@ -272,7 +273,9 @@ async fn precompressed_without_extension() {
let mut decoder = GzDecoder::new(&body[..]);
let mut decompressed = String::new();
decoder.read_to_string(&mut decompressed).unwrap();
assert_eq!(&decompressed, "Content.\n");

let correct = fs::read_to_string("../test-files/extensionless_precompressed").unwrap();
assert_eq!(decompressed, correct);
}

#[tokio::test]
Expand All @@ -293,7 +296,9 @@ async fn missing_precompressed_without_extension_fallbacks_to_uncompressed() {

let body = res.into_body().collect().await.unwrap().to_bytes();
let body = String::from_utf8(body.to_vec()).unwrap();
assert_eq!(&body, "Content.\n");

let correct = fs::read_to_string("../test-files/extensionless_precompressed_missing").unwrap();
assert_eq!(body, correct);
}

#[tokio::test]
Expand Down

0 comments on commit 7dedf26

Please sign in to comment.