Skip to content

Commit 3dce142

Browse files
committed
feat: spawn test in the background
1 parent 49f20b8 commit 3dce142

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

Diff for: src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use actix_web::{web, App, HttpRequest, HttpResponse, HttpServer, Responder, dev::Server};
1+
use actix_web::{dev::Server, web, App, HttpRequest, HttpResponse, HttpServer, Responder};
22

33
async fn greet(req: HttpRequest) -> impl Responder {
44
let name = req.match_info().get("name").unwrap_or("world");

Diff for: src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use robust_rust::run;
22

3-
#[actix_web::main]
3+
#[tokio::main]
44
async fn main() -> std::io::Result<()> {
55
run()?.await
66
}

Diff for: tests/health_check.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
use reqwest::Client;
2+
use robust_rust::run;
23

34
#[tokio::test]
45
async fn health_check_works() {
56
// Arrange
6-
spawn_app().await.expect("Failed to spawn our app.");
7+
spawn_app();
78
// We need to bring in `reqwest`
89
// to perform HTTP requests against our
910
let client = Client::new();
@@ -18,6 +19,10 @@ async fn health_check_works() {
1819
assert_eq!(Some(19), response.content_length());
1920
}
2021

21-
async fn spawn_app() -> std::io::Result<()> {
22-
Ok(())
22+
23+
#[allow(clippy::let_underscore_future)]
24+
fn spawn_app() {
25+
let server = run().expect("Failed to bind address");
26+
27+
let _ = tokio::spawn(server);
2328
}

0 commit comments

Comments
 (0)