-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improvement: attempted to make static_asset test more robust, doesn't…
… work yet
- Loading branch information
1 parent
7f66083
commit c37b484
Showing
7 changed files
with
103 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// tests/integration/index.rs | ||
|
||
use crate::helpers::TestApi; | ||
use pavex::http::StatusCode; | ||
|
||
#[tokio::test] | ||
async fn index_works() { | ||
let api = TestApi::spawn().await; | ||
|
||
let response = api.get_index().await; | ||
|
||
assert_eq!(response.status(), StatusCode::OK); | ||
|
||
let response_header = response | ||
.headers() | ||
.get("Content-Type") | ||
.expect("Expected Content-Type header in response."); | ||
|
||
let response_header_str = response_header.to_str().expect("Unable to get the response header text"); | ||
|
||
let expected_header_str = "text/html; charset=utf-8"; | ||
|
||
assert_eq!(response_header_str, expected_header_str); | ||
|
||
let response_body = response.text().await.unwrap(); | ||
|
||
assert!( | ||
response_body.contains("<!DOCTYPE html>"), | ||
"Response body does not contain expected HTML." | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
mod helpers; | ||
mod index; | ||
mod ping; | ||
mod static_asset; | ||
mod storage_create; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// tests/integration/static_asset.rs | ||
|
||
use crate::helpers::TestApi; | ||
use pavex::http::StatusCode; | ||
|
||
#[tokio::test] | ||
async fn static_asset_works() { | ||
let api = TestApi::spawn().await; | ||
|
||
let filename = "test.css"; | ||
|
||
let response = api.get_static_asset(filename).await; | ||
|
||
assert_eq!(response.status(), StatusCode::OK); | ||
|
||
let response_header = response | ||
.headers() | ||
.get("Content-Type") | ||
.expect("Expected Content-Type header in response."); | ||
|
||
let response_header_str = response_header.to_str().expect("Unable to get the response header text"); | ||
|
||
let expected_header_str = "text/css; charset=utf-8"; | ||
|
||
assert_eq!(response_header_str, expected_header_str); | ||
|
||
} |