| 1 | |
| 2 | |
| 3 | |
| 4 | use http::header::{ACCEPT_ENCODING, CONTENT_ENCODING}; |
| 5 | use topcoat::router::Body; |
| 6 | |
| 7 | #[tokio::test] |
| 8 | async fn public_css_asset_is_gzipped() { |
| 9 | let dir = tempfile::tempdir().expect("tempdir"); |
| 10 | let state = crate::test_support::test_state(dir.path()).await; |
| 11 | let router = crate::test_support::app_router(state); |
| 12 | let request = http::Request::builder() |
| 13 | .uri("/assets/main.css") |
| 14 | .header(ACCEPT_ENCODING, "gzip") |
| 15 | .body(Body::empty()) |
| 16 | .expect("request"); |
| 17 | let response = router.handle(request).await; |
| 18 | assert_eq!( |
| 19 | response |
| 20 | .headers() |
| 21 | .get(CONTENT_ENCODING) |
| 22 | .map(|v| v.to_str().expect("ascii")), |
| 23 | Some("gzip") |
| 24 | ); |
| 25 | } |