diff options
Diffstat (limited to 'src/test_support.rs')
| -rw-r--r-- | src/test_support.rs | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/test_support.rs b/src/test_support.rs index 8f2d2bf..d6a0a96 100644 --- a/src/test_support.rs +++ b/src/test_support.rs @@ -7,24 +7,21 @@ #![allow(clippy::unwrap_used, clippy::expect_used)] -use crate::server::{AppState, run_with_listener}; -use anyhow::Result; +use crate::server::{AppState, run_with_server}; use std::path::{Path, PathBuf}; -use tokio::net::TcpListener; +use std::sync::Arc; +use tiny_http::Server; -/// Start the HTTP server on the given listener, shutting down when `shutdown` resolves. +/// Start the HTTP server, returning a `JoinHandle` for the request-handling thread. /// -/// The server behaves identically to production — same middleware, same handlers. -/// -/// # Errors -/// -/// Returns an error if the server encounters a fatal I/O error. -pub async fn run_server( +/// The server shuts down when `shutdown` resolves (calls `server.unblock()`). +/// Callers should join the handle after triggering shutdown. +pub fn run_server( state: AppState, - listener: TcpListener, + server: Arc<Server>, shutdown: impl std::future::Future<Output = ()> + Send + 'static, -) -> Result<()> { - run_with_listener(state, listener, shutdown).await +) -> std::thread::JoinHandle<()> { + run_with_server(state, server, shutdown) } /// Install the SIGHUP configuration-reload handler for `state`. |
