diff --git a/src/main.rs b/src/main.rs index 5dc9266..bf78517 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,9 @@ mod models; mod routes; +#[cfg(test)] +mod tests; + use actix_cors::Cors; use actix_web::middleware::Logger; use actix_web::{web, App, HttpServer}; diff --git a/src/tests.rs b/src/tests.rs new file mode 100644 index 0000000..52083b7 --- /dev/null +++ b/src/tests.rs @@ -0,0 +1,13 @@ +use actix_web::{test, App, http::header::ContentType}; + +use crate::routes::home; + +#[actix_web::test] +async fn test_index_get() { + let app = test::init_service(App::new().service(home)).await; + let req = test::TestRequest::default() + .insert_header(ContentType::plaintext()) + .to_request(); + let resp = test::call_service(&app, req).await; + assert!(resp.status().is_success()); +} \ No newline at end of file