Skip to content

Commit

Permalink
start tests
Browse files Browse the repository at this point in the history
  • Loading branch information
berinaniesh committed Nov 1, 2023
1 parent e256477 commit 0235100
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
13 changes: 13 additions & 0 deletions src/tests.rs
Original file line number Diff line number Diff line change
@@ -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());
}

0 comments on commit 0235100

Please sign in to comment.