Code cleanup
This commit is contained in:
+45
-55
@@ -510,7 +510,9 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Returns coverart response and song_queue_id
|
// Returns coverart response and song_queue_id
|
||||||
pub async fn queue_song_and_coverart_flow(app: &axum::Router) -> Result<(axum::response::Response, uuid::Uuid), std::convert::Infallible> {
|
pub async fn queue_song_and_coverart_flow(
|
||||||
|
app: &axum::Router,
|
||||||
|
) -> Result<(axum::response::Response, uuid::Uuid), std::convert::Infallible> {
|
||||||
match queue_song_flow(&app).await {
|
match queue_song_flow(&app).await {
|
||||||
Ok(song_response) => {
|
Ok(song_response) => {
|
||||||
let resp = super::get_resp_data::<
|
let resp = super::get_resp_data::<
|
||||||
@@ -544,9 +546,7 @@ mod tests {
|
|||||||
eprintln!("Song: {:?}", song);
|
eprintln!("Song: {:?}", song);
|
||||||
|
|
||||||
match queue_coverart_flow(&app, &song_queue_id).await {
|
match queue_coverart_flow(&app, &song_queue_id).await {
|
||||||
Ok(response) => {
|
Ok(response) => Ok((response, song_queue_id)),
|
||||||
Ok((response, song_queue_id))
|
|
||||||
}
|
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
assert!(false, "Error: {:?}", err);
|
assert!(false, "Error: {:?}", err);
|
||||||
Err(err)
|
Err(err)
|
||||||
@@ -567,50 +567,49 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// pub async
|
// pub async
|
||||||
/*
|
/*
|
||||||
let done = crate::callers::song::status::DONE;
|
let done = crate::callers::song::status::DONE;
|
||||||
let payload = serde_json::json!({
|
let payload = serde_json::json!({
|
||||||
"id": &resp.data[0].id,
|
"id": &resp.data[0].id,
|
||||||
"status": done,
|
"status": done,
|
||||||
});
|
});
|
||||||
|
|
||||||
match app
|
match app
|
||||||
.clone()
|
.clone()
|
||||||
.oneshot(
|
.oneshot(
|
||||||
axum::http::Request::builder()
|
axum::http::Request::builder()
|
||||||
.method(axum::http::Method::PATCH)
|
.method(axum::http::Method::PATCH)
|
||||||
.uri(crate::callers::endpoints::QUEUESONG)
|
.uri(crate::callers::endpoints::QUEUESONG)
|
||||||
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
||||||
.body(axum::body::Body::from(payload.to_string()))
|
.body(axum::body::Body::from(payload.to_string()))
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
let resp = get_resp_data::<
|
let resp = get_resp_data::<
|
||||||
crate::callers::song::response::update_status::Response,
|
crate::callers::song::response::update_status::Response,
|
||||||
>(response)
|
>(response)
|
||||||
.await;
|
.await;
|
||||||
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||||
let changed_status = &resp.data[0];
|
let changed_status = &resp.data[0];
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
*old, changed_status.old_status,
|
*old, changed_status.old_status,
|
||||||
"Old status does not match"
|
"Old status does not match"
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
done, changed_status.new_status,
|
done, changed_status.new_status,
|
||||||
"New status does not match"
|
"New status does not match"
|
||||||
);
|
);
|
||||||
}
|
|
||||||
Err(err) => {
|
|
||||||
assert!(false, "Error: {:?}", err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
*/
|
Err(err) => {
|
||||||
|
assert!(false, "Error: {:?}", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub async fn resp_to_bytes(
|
pub async fn resp_to_bytes(
|
||||||
response: axum::response::Response,
|
response: axum::response::Response,
|
||||||
) -> Result<axum::body::Bytes, axum::Error> {
|
) -> Result<axum::body::Bytes, axum::Error> {
|
||||||
@@ -776,8 +775,6 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Send request
|
// Send request
|
||||||
/*
|
/*
|
||||||
match song_queue_req(&app).await {
|
match song_queue_req(&app).await {
|
||||||
@@ -847,8 +844,8 @@ mod tests {
|
|||||||
"Queued data should not be empty"
|
"Queued data should not be empty"
|
||||||
);
|
);
|
||||||
|
|
||||||
let temp_file = tempfile::tempdir()
|
let temp_file =
|
||||||
.expect("Could not create test directory");
|
tempfile::tempdir().expect("Could not create test directory");
|
||||||
let test_dir = String::from(temp_file.path().to_str().unwrap());
|
let test_dir = String::from(temp_file.path().to_str().unwrap());
|
||||||
let new_file = format!("{}/new_file.flac", test_dir);
|
let new_file = format!("{}/new_file.flac", test_dir);
|
||||||
|
|
||||||
@@ -878,10 +875,7 @@ mod tests {
|
|||||||
axum::http::Request::builder()
|
axum::http::Request::builder()
|
||||||
.method(axum::http::Method::PATCH)
|
.method(axum::http::Method::PATCH)
|
||||||
.uri(uri)
|
.uri(uri)
|
||||||
.header(
|
.header(axum::http::header::CONTENT_TYPE, content_type)
|
||||||
axum::http::header::CONTENT_TYPE,
|
|
||||||
content_type,
|
|
||||||
)
|
|
||||||
.body(axum::body::Body::from_stream(body))
|
.body(axum::body::Body::from_stream(body))
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
)
|
)
|
||||||
@@ -1085,8 +1079,6 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_song_metadata_queue() {
|
async fn test_song_metadata_queue() {
|
||||||
let tm_pool = db_mgr::get_pool().await.unwrap();
|
let tm_pool = db_mgr::get_pool().await.unwrap();
|
||||||
@@ -1280,7 +1272,6 @@ mod tests {
|
|||||||
let _ = db_mgr::drop_database(&tm_pool, &db_name).await;
|
let _ = db_mgr::drop_database(&tm_pool, &db_name).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_fetch_coverart_queue_without_data() {
|
async fn test_fetch_coverart_queue_without_data() {
|
||||||
let tm_pool = db_mgr::get_pool().await.unwrap();
|
let tm_pool = db_mgr::get_pool().await.unwrap();
|
||||||
@@ -1437,7 +1428,6 @@ mod tests {
|
|||||||
let _ = db_mgr::drop_database(&tm_pool, &db_name).await;
|
let _ = db_mgr::drop_database(&tm_pool, &db_name).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_create_song() {
|
async fn test_create_song() {
|
||||||
let tm_pool = db_mgr::get_pool().await.unwrap();
|
let tm_pool = db_mgr::get_pool().await.unwrap();
|
||||||
|
|||||||
Reference in New Issue
Block a user