From acb36fa463df278a0ca1c2e8f685b9707b03ef6e Mon Sep 17 00:00:00 2001 From: "Anthony M. Bonafide" Date: Wed, 20 Mar 2024 00:00:16 -0400 Subject: [PATCH] Fix tests Signed-off-by: Anthony M. Bonafide --- Cargo.toml | 6 ------ src/lib.rs | 4 ++-- tests/health_check.rs | 6 +++--- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 453f637..ec953a8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,12 +10,6 @@ path = "src/lib.rs" path = "src/main.rs" name = "zero2prod" -[target.aarch64-apple-darwin] -rustflags = ["-C", "link-arg=-fuse-ld=/opt/homebrew/opt/llvm/bin/ld64.lld"] - -[target.x86_64-unknown-linux-gnu] -rustflags = ["-C", "linker=clang", "-C", "link-arg=-fuse-ld=lld"] - [dependencies] actix-web = "4" tokio = { version = "1", features = ["macros", "rt-multi-thread"] } diff --git a/src/lib.rs b/src/lib.rs index 5970313..420a2c9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,9 +6,9 @@ async fn health_check() -> impl Responder { HttpResponse::Ok().finish() } -pub fn run(tcpListener: TcpListener) -> Result { +pub fn run(tcp_listener: TcpListener) -> Result { let server = HttpServer::new(|| App::new().route("/health_check", web::get().to(health_check))) - .bind(tcpListener.local_addr().unwrap())? + .listen(tcp_listener)? .run(); Ok(server) diff --git a/tests/health_check.rs b/tests/health_check.rs index 62d31ce..adf7fb3 100644 --- a/tests/health_check.rs +++ b/tests/health_check.rs @@ -7,7 +7,7 @@ async fn health_check_works() { let client = reqwest::Client::new(); let response = client - .get(format!("{}/health_check", address)) + .get(format!("{}/health_check", &address)) .send() .await .expect("Failed to execute request"); @@ -20,7 +20,7 @@ fn spawn_app() -> String { let listener = TcpListener::bind("127.0.0.1:0").expect("Failed to bind port"); let port = listener.local_addr().unwrap().port(); let server = zero2prod::run(listener).expect("Failed to bind address"); - let _ = tokio::spawn(server); - + let _server_run = tokio::spawn(server); + std::mem::drop(_server_run); format!("http://127.0.0.1:{}", port) }