diff --git a/actix-test/CHANGES.md b/actix-test/CHANGES.md index e3a66c663..2a30ee95b 100644 --- a/actix-test/CHANGES.md +++ b/actix-test/CHANGES.md @@ -2,6 +2,7 @@ ## Unreleased - 2023-xx-xx +- Add `TestServerConfig::workers()` setter method - Minimum supported Rust version (MSRV) is now 1.65 due to transitive `time` dependency. ## 0.1.1 - 2023-02-26 diff --git a/actix-test/src/lib.rs b/actix-test/src/lib.rs index 7781edab4..c667e564d 100644 --- a/actix-test/src/lib.rs +++ b/actix-test/src/lib.rs @@ -154,7 +154,10 @@ where let srv_cfg = cfg.clone(); let timeout = cfg.client_request_timeout; - let builder = Server::build().workers(1).disable_signals().system_exit(); + let builder = Server::build() + .workers(cfg.workers) + .disable_signals() + .system_exit(); let srv = match srv_cfg.stream { StreamType::Tcp => match srv_cfg.tp { @@ -367,6 +370,7 @@ pub struct TestServerConfig { stream: StreamType, client_request_timeout: Duration, port: u16, + workers: usize, } impl Default for TestServerConfig { @@ -383,6 +387,7 @@ impl TestServerConfig { stream: StreamType::Tcp, client_request_timeout: Duration::from_secs(5), port: 0, + workers: 1, } } @@ -425,6 +430,14 @@ impl TestServerConfig { self.port = port; self } + + /// Sets number of workers in the test server process. + /// + /// By default, the server boots with 1 worker + pub fn workers(mut self, workers: usize) -> Self { + self.workers = workers; + self + } } /// A basic HTTP server controller that simplifies the process of writing integration tests for