Added test
This commit is contained in:
+70
-19
@@ -1820,6 +1820,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub mod after_song_queue {
|
pub mod after_song_queue {
|
||||||
|
use futures::StreamExt;
|
||||||
use tower::ServiceExt;
|
use tower::ServiceExt;
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -1841,15 +1842,7 @@ mod tests {
|
|||||||
|
|
||||||
let app = super::init::app(pool).await;
|
let app = super::init::app(pool).await;
|
||||||
|
|
||||||
let mut id = uuid::Uuid::nil();
|
let id = test_data::coverart_id().await.unwrap();
|
||||||
match uuid::Uuid::parse_str("44cf7940-34ff-489f-9124-d0ec90a55af9") {
|
|
||||||
Ok(val) => {
|
|
||||||
id = val;
|
|
||||||
}
|
|
||||||
Err(err) => {
|
|
||||||
assert!(false, "Error: {err:?}");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let uri = format!("{}?id={id}", crate::callers::endpoints::GETSONGS);
|
let uri = format!("{}?id={id}", crate::callers::endpoints::GETSONGS);
|
||||||
|
|
||||||
@@ -1902,16 +1895,7 @@ mod tests {
|
|||||||
|
|
||||||
let app = super::init::app(pool).await;
|
let app = super::init::app(pool).await;
|
||||||
|
|
||||||
let mut id = uuid::Uuid::nil();
|
let id = test_data::coverart_id().await.unwrap();
|
||||||
|
|
||||||
match uuid::Uuid::parse_str("996122cd-5ae9-4013-9934-60768d3006ed") {
|
|
||||||
Ok(val) => {
|
|
||||||
id = val;
|
|
||||||
}
|
|
||||||
Err(err) => {
|
|
||||||
assert!(false, "Error: {err:?}");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let uri = format!("{}?id={id}", crate::callers::endpoints::GETCOVERART);
|
let uri = format!("{}?id={id}", crate::callers::endpoints::GETCOVERART);
|
||||||
|
|
||||||
@@ -1944,5 +1928,72 @@ mod tests {
|
|||||||
|
|
||||||
let _ = super::db_mgr::drop_database(&tm_pool, &db_name).await;
|
let _ = super::db_mgr::drop_database(&tm_pool, &db_name).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub mod test_data {
|
||||||
|
pub async fn song_id() -> Result<uuid::Uuid, uuid::Error> {
|
||||||
|
uuid::Uuid::parse_str("44cf7940-34ff-489f-9124-d0ec90a55af9")
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn coverart_id() -> Result<uuid::Uuid, uuid::Error> {
|
||||||
|
uuid::Uuid::parse_str("996122cd-5ae9-4013-9934-60768d3006ed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn test_stream_song() {
|
||||||
|
let tm_pool = super::db_mgr::get_pool().await.unwrap();
|
||||||
|
let db_name = super::db_mgr::generate_db_name().await;
|
||||||
|
|
||||||
|
match super::db_mgr::create_database(&tm_pool, &db_name).await {
|
||||||
|
Ok(_) => {
|
||||||
|
println!("Success");
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
assert!(false, "Error: {:?}", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let pool = super::db_mgr::connect_to_db(&db_name).await.unwrap();
|
||||||
|
super::db_mgr::migrations(&pool).await;
|
||||||
|
|
||||||
|
let app = super::init::app(pool).await;
|
||||||
|
|
||||||
|
let id = test_data::song_id().await.unwrap();
|
||||||
|
|
||||||
|
let my_url = crate::callers::endpoints::STREAMSONG;
|
||||||
|
let last = my_url.len() - 5;
|
||||||
|
let uri = format!("{}/{id}", &my_url[0..last]);
|
||||||
|
|
||||||
|
match app
|
||||||
|
.clone()
|
||||||
|
.oneshot(
|
||||||
|
axum::http::Request::builder()
|
||||||
|
.method(axum::http::Method::GET)
|
||||||
|
.uri(&uri)
|
||||||
|
.body(axum::body::Body::empty())
|
||||||
|
.unwrap(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(response) => {
|
||||||
|
let e = response.into_body();
|
||||||
|
let mut data = e.into_data_stream();
|
||||||
|
while let Some(chunk) = data.next().await {
|
||||||
|
match chunk {
|
||||||
|
Ok(_data) => {
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
assert!(false, "Error: {err:?}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
assert!(false, "Error: {err:?}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let _ = super::db_mgr::drop_database(&tm_pool, &db_name).await;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user