mirror of
https://github.com/LukeMathWalker/zero-to-production.git
synced 2024-12-18 22:16:40 +00:00
Fix failing test.
This commit is contained in:
parent
f2ea222c96
commit
3359c5f921
2 changed files with 6 additions and 5 deletions
|
@ -10,7 +10,7 @@ use std::net::TcpListener;
|
|||
use tracing_actix_web::TracingLogger;
|
||||
|
||||
pub struct Application {
|
||||
address: String,
|
||||
port: u16,
|
||||
server: Server,
|
||||
}
|
||||
|
||||
|
@ -35,13 +35,14 @@ impl Application {
|
|||
configuration.application.host, configuration.application.port
|
||||
);
|
||||
let listener = TcpListener::bind(&address)?;
|
||||
let port = listener.local_addr().unwrap().port();
|
||||
let server = run(listener, connection_pool, email_client)?;
|
||||
|
||||
Ok(Self { address, server })
|
||||
Ok(Self { port, server })
|
||||
}
|
||||
|
||||
pub fn address(&self) -> &str {
|
||||
&self.address
|
||||
pub fn port(&self) -> u16 {
|
||||
self.port
|
||||
}
|
||||
|
||||
pub async fn run_until_stopped(self) -> Result<(), std::io::Error> {
|
||||
|
|
|
@ -48,7 +48,7 @@ pub async fn spawn_app() -> TestApp {
|
|||
let application = Application::build(configuration.clone())
|
||||
.await
|
||||
.expect("Failed to build application.");
|
||||
let address = application.address().to_owned();
|
||||
let address = format!("http://localhost:{}", application.port());
|
||||
let _ = tokio::spawn(application.run_until_stopped());
|
||||
|
||||
TestApp {
|
||||
|
|
Loading…
Reference in a new issue