diff --git a/pagetop/Cargo.toml b/pagetop/Cargo.toml index 3ea567e3..3cf6584a 100644 --- a/pagetop/Cargo.toml +++ b/pagetop/Cargo.toml @@ -77,9 +77,6 @@ optional = true version = "0.11.0" optional = true -[dev-dependencies] -tokio = { version = "1.28.2", features = ["macros", "rt-multi-thread"] } - [build-dependencies] pagetop-build = { version = "0.0", path = "../pagetop-build" } diff --git a/pagetop/src/app.rs b/pagetop/src/app.rs index dbb39ddd..83e17065 100644 --- a/pagetop/src/app.rs +++ b/pagetop/src/app.rs @@ -86,6 +86,10 @@ impl Application { pub fn run(self) -> Result { Ok(self.server) } + + pub fn server(self) -> Server { + self.server + } } fn print_on_startup() { diff --git a/pagetop/tests/health_check.rs b/pagetop/tests/health_check.rs index dd980796..0898211a 100644 --- a/pagetop/tests/health_check.rs +++ b/pagetop/tests/health_check.rs @@ -1,12 +1,15 @@ +use pagetop::prelude::*; + +struct HealthCheck; + +impl ModuleTrait for HealthCheck {} + async fn spawn_app() { - let server = pagetop::Application::prepare(None) - .await? - .run()? - .expect("Failed to prepare server"); - let _ = tokio::spawn(server); + let server = Application::prepare(&HealthCheck).unwrap().server(); + let _ = actix_web::rt::spawn(server); } -#[tokio::test] +#[actix_web::test] async fn health_check_works() { spawn_app(); }