Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Anthony M. Bonafide <AnthonyMBonafide@gmail.com>
  • Loading branch information
AnthonyMBonafide committed Mar 20, 2024
1 parent d4811be commit acb36fa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
6 changes: 0 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ async fn health_check() -> impl Responder {
HttpResponse::Ok().finish()
}

pub fn run(tcpListener: TcpListener) -> Result<Server, std::io::Error> {
pub fn run(tcp_listener: TcpListener) -> Result<Server, std::io::Error> {
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)
Expand Down
6 changes: 3 additions & 3 deletions tests/health_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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)
}

0 comments on commit acb36fa

Please sign in to comment.