34 lines
919 B
Rust
34 lines
919 B
Rust
use player::Backend;
|
|
|
|
#[tokio::test]
|
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
let listener = tokio::net::TcpListener::bind("0.0.0.0:0").await?;
|
|
let addr = listener.local_addr().unwrap();
|
|
|
|
// Start server in background task
|
|
tokio::spawn(async move {
|
|
if let Err(e) = player::start(
|
|
"Test Feed".into(),
|
|
"http://test.example".into(),
|
|
"Test description".into(),
|
|
vec!["Test Journal".into()],
|
|
listener,
|
|
Backend::Prod,
|
|
)
|
|
.await
|
|
{
|
|
eprintln!("Server failed to start: {e}");
|
|
}
|
|
});
|
|
|
|
// Allow server startup time
|
|
tokio::time::sleep(tokio::time::Duration::from_millis(3000)).await;
|
|
|
|
// Verify route responds with success status
|
|
let response = reqwest::get(format!("http://{addr}/")).await.unwrap();
|
|
|
|
assert_eq!(response.status(), 200);
|
|
|
|
Ok(())
|
|
}
|