Hurl tests for project api.
This commit is contained in:
parent
4895f7c4b7
commit
d8094c4812
3 changed files with 406 additions and 5 deletions
|
|
@ -1,7 +1,12 @@
|
|||
use std::path::Path;
|
||||
|
||||
use axum::{Router, routing::get};
|
||||
use axum_test::{TestServer, TestServerConfig, Transport};
|
||||
use hurl::report::html::{Testcase, write_report};
|
||||
use hurl::runner::{self, RunnerOptions, Value, VariableSet};
|
||||
use hurl::util::logger::LoggerOptionsBuilder;
|
||||
use hurl_core::input::Input;
|
||||
use tower_http::trace::TraceLayer;
|
||||
|
||||
async fn create_app() -> Router {
|
||||
use backend::database::{DatabaseConfig, create_pool};
|
||||
|
|
@ -49,11 +54,14 @@ async fn run_hurl_test(hurl_file_path: &str) {
|
|||
let logger_opts = LoggerOptionsBuilder::new().build();
|
||||
let result = runner::run(&content, None, &runner_opts, &variables, &logger_opts).unwrap();
|
||||
|
||||
assert!(
|
||||
result.success,
|
||||
"Hurl test failed for {}: {:?}",
|
||||
hurl_file_path, result
|
||||
);
|
||||
let input = Input::new(hurl_file_path);
|
||||
let test_case = Testcase::from(&result, &input);
|
||||
test_case
|
||||
.write_html(&content, &result.entries, Path::new("reports/store"), &[])
|
||||
.expect("Failed to write html files");
|
||||
write_report(Path::new("reports/"), &vec![test_case]).expect("Failed to write report");
|
||||
|
||||
assert!(result.success, "Hurl test failed for {}", hurl_file_path);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
|
|
@ -75,3 +83,8 @@ async fn test_update_tasks_api() {
|
|||
async fn test_delete_tasks_api() {
|
||||
run_hurl_test("./tests/api/delete_tasks.hurl").await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn test_projects_api() {
|
||||
run_hurl_test("./tests/api/projects.hurl").await;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue