-
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.
test: Added additional tests and moved steale test to its own directory
- Loading branch information
Showing
5 changed files
with
561 additions
and
303 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
mod archive_basic_test; | ||
mod archive_multihost_test; | ||
mod archive_multijursidiction_test; | ||
mod stelae; |
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,64 @@ | ||
use actix_http::{Method, Request}; | ||
use actix_service::Service; | ||
use actix_web::body::MessageBody; | ||
use actix_web::dev::ServiceResponse; | ||
use actix_web::{test, Error}; | ||
mod stelae_basic_test; | ||
mod stelae_multihost_test; | ||
|
||
/// Helper method which test all `fille_paths`` in `org_name`/`repo_name` repository on `branch_name`` branch with `expected` result | ||
async fn test_stelae_paths( | ||
org_name: &str, | ||
repo_name: &str, | ||
file_paths: Vec<&str>, | ||
branch_name: &str, | ||
app: &impl Service<Request, Response = ServiceResponse<impl MessageBody>, Error = Error>, | ||
expected: bool, | ||
) { | ||
for file_path in file_paths { | ||
let req = test::TestRequest::get() | ||
.uri(&format!( | ||
"/_stelae/{}/{}?commitish={}&remainder={}", | ||
org_name, repo_name, branch_name, file_path | ||
)) | ||
.to_request(); | ||
|
||
let resp = test::call_service(&app, req).await; | ||
let actual = if expected { | ||
resp.status().is_success() | ||
} else { | ||
resp.status().is_client_error() | ||
}; | ||
let expected = true; | ||
assert_eq!(actual, expected); | ||
} | ||
} | ||
|
||
/// Helper method which test all `fille_paths`` in `org_name`/`repo_name` repository on `branch_name`` branch with `expected` result | ||
async fn test_stelae_paths_with_head_method( | ||
org_name: &str, | ||
repo_name: &str, | ||
file_paths: Vec<&str>, | ||
branch_name: &str, | ||
app: &impl Service<Request, Response = ServiceResponse<impl MessageBody>, Error = Error>, | ||
expected: bool, | ||
) { | ||
for file_path in file_paths { | ||
let req = test::TestRequest::default() | ||
.method(Method::HEAD) | ||
.uri(&format!( | ||
"/_stelae/{}/{}?commitish={}&remainder={}", | ||
org_name, repo_name, branch_name, file_path | ||
)) | ||
.to_request(); | ||
|
||
let resp = test::call_service(&app, req).await; | ||
let actual = if expected { | ||
resp.status().is_success() | ||
} else { | ||
resp.status().is_client_error() | ||
}; | ||
let expected = true; | ||
assert_eq!(actual, expected); | ||
} | ||
} |
Oops, something went wrong.