Closed JonnyWaffles closed 10 months ago
When I skip ahead and use the TcpListener
everything works, but I don't understand why the simpler hard coded port 8000 test fails when I know I can curl it when I do a build.
Never mind I got owned by the extra async in my spawn app function! Damn my Python habits.
The fix is
fn spawn_app() {
let server = zero2prod::run().expect("Failed to bind address");
let _ = tokio::spawn(server);
}
Removing the async. Yikes.
Hi friends, picked up the book and working through the examples. I have this strange scenario in Chapter 3, where my app works if I build and run, but not when the test executes.
Here's a link to my progress thus far https://github.com/JonnyWaffles/zero2prod/tree/b17dc67098881ed38b05fee89100858752b13946.
When I run the test kit
I see
The strange part is if I build and run without testing, I can curl the app, and it works in Chrome. Just not when testing. It's like the
tokio::spawn(server)
isn't ready to go when I make the request above.