tsk-206: Moving request functions to their own module in testing #238
Generated
+1
-1
@@ -964,7 +964,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "icarus"
|
name = "icarus"
|
||||||
version = "0.3.20"
|
version = "0.3.21"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"axum",
|
"axum",
|
||||||
"axum-extra",
|
"axum-extra",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "icarus"
|
name = "icarus"
|
||||||
version = "0.3.20"
|
version = "0.3.21"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
rust-version = "1.90"
|
rust-version = "1.90"
|
||||||
|
|
||||||
|
|||||||
+314
-251
@@ -463,236 +463,284 @@ mod tests {
|
|||||||
format!("Bearer {token}")
|
format!("Bearer {token}")
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Put the *_req() functions in their own module
|
mod request {
|
||||||
async fn song_queue_req(
|
use common_multipart_rfc7578::client::multipart::{
|
||||||
app: &axum::Router,
|
Body as MultipartBody, Form as MultipartForm,
|
||||||
) -> Result<axum::response::Response, std::convert::Infallible> {
|
};
|
||||||
// Create multipart form
|
use tower::ServiceExt;
|
||||||
let mut form = MultipartForm::default();
|
|
||||||
let _ = form.add_file("flac", "tests/I/track01.flac");
|
|
||||||
|
|
||||||
// Create request
|
pub async fn song_queue_req(
|
||||||
let content_type = form.content_type();
|
app: &axum::Router,
|
||||||
let body = MultipartBody::from(form);
|
) -> Result<axum::response::Response, std::convert::Infallible> {
|
||||||
let req = axum::http::Request::builder()
|
// Create multipart form
|
||||||
.method(axum::http::Method::POST)
|
let mut form = MultipartForm::default();
|
||||||
.uri(crate::callers::queue::endpoints::QUEUESONG)
|
let _ = form.add_file("flac", "tests/I/track01.flac");
|
||||||
.header(axum::http::header::CONTENT_TYPE, content_type)
|
|
||||||
.header(axum::http::header::AUTHORIZATION, bearer_auth().await)
|
|
||||||
.body(axum::body::Body::from_stream(body))
|
|
||||||
.unwrap();
|
|
||||||
app.clone().oneshot(req).await
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn song_queue_link_req(
|
// Create request
|
||||||
app: &axum::Router,
|
let content_type = form.content_type();
|
||||||
song_queue_id: &uuid::Uuid,
|
let body = MultipartBody::from(form);
|
||||||
user_id: &uuid::Uuid,
|
let req = axum::http::Request::builder()
|
||||||
) -> Result<axum::response::Response, std::convert::Infallible> {
|
.method(axum::http::Method::POST)
|
||||||
let payload = serde_json::json!({
|
.uri(crate::callers::queue::endpoints::QUEUESONG)
|
||||||
"song_queue_id": song_queue_id,
|
.header(axum::http::header::CONTENT_TYPE, content_type)
|
||||||
"user_id": user_id
|
.header(
|
||||||
});
|
axum::http::header::AUTHORIZATION,
|
||||||
|
super::bearer_auth().await,
|
||||||
|
)
|
||||||
|
.body(axum::body::Body::from_stream(body))
|
||||||
|
.unwrap();
|
||||||
|
app.clone().oneshot(req).await
|
||||||
|
}
|
||||||
|
|
||||||
let req = axum::http::Request::builder()
|
pub async fn song_queue_link_req(
|
||||||
.method(axum::http::Method::PATCH)
|
app: &axum::Router,
|
||||||
.uri(crate::callers::queue::endpoints::QUEUESONGLINKUSERID)
|
song_queue_id: &uuid::Uuid,
|
||||||
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
user_id: &uuid::Uuid,
|
||||||
.header(axum::http::header::AUTHORIZATION, bearer_auth().await)
|
) -> Result<axum::response::Response, std::convert::Infallible> {
|
||||||
.body(axum::body::Body::from(payload.to_string()))
|
let payload = serde_json::json!({
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
app.clone().oneshot(req).await
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn fetch_queue_req(
|
|
||||||
app: &axum::Router,
|
|
||||||
) -> Result<axum::response::Response, std::convert::Infallible> {
|
|
||||||
let fetch_req = axum::http::Request::builder()
|
|
||||||
.method(axum::http::Method::GET)
|
|
||||||
.uri(crate::callers::queue::endpoints::NEXTQUEUESONG)
|
|
||||||
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
|
||||||
.header(axum::http::header::AUTHORIZATION, bearer_auth().await)
|
|
||||||
.body(axum::body::Body::empty())
|
|
||||||
.unwrap();
|
|
||||||
app.clone().oneshot(fetch_req).await
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn fetch_metadata_queue_req(
|
|
||||||
app: &axum::Router,
|
|
||||||
id: &uuid::Uuid,
|
|
||||||
) -> Result<axum::response::Response, std::convert::Infallible> {
|
|
||||||
let uri = format!(
|
|
||||||
"{}?id={}",
|
|
||||||
crate::callers::queue::endpoints::QUEUEMETADATA,
|
|
||||||
id
|
|
||||||
);
|
|
||||||
|
|
||||||
let req = axum::http::Request::builder()
|
|
||||||
.method(axum::http::Method::GET)
|
|
||||||
.uri(uri)
|
|
||||||
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
|
||||||
.header(axum::http::header::AUTHORIZATION, bearer_auth().await)
|
|
||||||
.body(axum::body::Body::empty())
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
app.clone().oneshot(req).await
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn fetch_queue_data_req(
|
|
||||||
app: &axum::Router,
|
|
||||||
id: &uuid::Uuid,
|
|
||||||
) -> Result<axum::response::Response, std::convert::Infallible> {
|
|
||||||
let raw_uri = String::from(crate::callers::queue::endpoints::QUEUESONGDATA);
|
|
||||||
let end_index = raw_uri.len() - 4;
|
|
||||||
let mut uri: String = (&raw_uri[..end_index]).to_string();
|
|
||||||
uri += &id.to_string();
|
|
||||||
let req = axum::http::Request::builder()
|
|
||||||
.method(axum::http::Method::GET)
|
|
||||||
.uri(uri)
|
|
||||||
.header(axum::http::header::CONTENT_TYPE, "audio/flac")
|
|
||||||
.header(axum::http::header::AUTHORIZATION, bearer_auth().await)
|
|
||||||
.body(axum::body::Body::empty())
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
app.clone().oneshot(req).await
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn upload_coverart_queue_req(
|
|
||||||
app: &axum::Router,
|
|
||||||
) -> Result<axum::response::Response, std::convert::Infallible> {
|
|
||||||
let mut form = MultipartForm::default();
|
|
||||||
let _ = form.add_file("jpg", "tests/I/Coverart-1.jpg");
|
|
||||||
|
|
||||||
// Create request
|
|
||||||
let content_type = form.content_type();
|
|
||||||
let body = MultipartBody::from(form);
|
|
||||||
|
|
||||||
let req = axum::http::Request::builder()
|
|
||||||
.method(axum::http::Method::POST)
|
|
||||||
.uri(crate::callers::queue::endpoints::QUEUECOVERART)
|
|
||||||
.header(axum::http::header::CONTENT_TYPE, content_type)
|
|
||||||
.header(axum::http::header::AUTHORIZATION, bearer_auth().await)
|
|
||||||
.body(axum::body::Body::from_stream(body))
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
app.clone().oneshot(req).await
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn queue_metadata_req(
|
|
||||||
app: &axum::Router,
|
|
||||||
song_queue_id: &uuid::Uuid,
|
|
||||||
) -> Result<axum::response::Response, std::convert::Infallible> {
|
|
||||||
let payload = payload_data::queue_metadata_payload_data(&song_queue_id).await;
|
|
||||||
|
|
||||||
let req = axum::http::Request::builder()
|
|
||||||
.method(axum::http::Method::POST)
|
|
||||||
.uri(crate::callers::queue::endpoints::QUEUEMETADATA)
|
|
||||||
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
|
||||||
.header(axum::http::header::AUTHORIZATION, bearer_auth().await)
|
|
||||||
.body(axum::body::Body::from(payload.to_string()))
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
app.clone().oneshot(req).await
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn coverart_queue_song_queue_link_req(
|
|
||||||
app: &axum::Router,
|
|
||||||
coverart_id: &uuid::Uuid,
|
|
||||||
song_queue_id: &uuid::Uuid,
|
|
||||||
) -> Result<axum::response::Response, std::convert::Infallible> {
|
|
||||||
let payload = serde_json::json!(
|
|
||||||
{
|
|
||||||
"song_queue_id": song_queue_id,
|
"song_queue_id": song_queue_id,
|
||||||
"coverart_id" : coverart_id,
|
"user_id": user_id
|
||||||
});
|
});
|
||||||
let req = axum::http::Request::builder()
|
|
||||||
.method(axum::http::Method::PATCH)
|
|
||||||
.uri(crate::callers::queue::endpoints::QUEUECOVERARTLINK)
|
|
||||||
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
|
||||||
.header(axum::http::header::AUTHORIZATION, bearer_auth().await)
|
|
||||||
.body(axum::body::Body::from(payload.to_string()))
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
app.clone().oneshot(req).await
|
let req = axum::http::Request::builder()
|
||||||
}
|
.method(axum::http::Method::PATCH)
|
||||||
|
.uri(crate::callers::queue::endpoints::QUEUESONGLINKUSERID)
|
||||||
|
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
||||||
|
.header(
|
||||||
|
axum::http::header::AUTHORIZATION,
|
||||||
|
super::bearer_auth().await,
|
||||||
|
)
|
||||||
|
.body(axum::body::Body::from(payload.to_string()))
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
async fn create_coverart_req(
|
app.clone().oneshot(req).await
|
||||||
app: &axum::Router,
|
}
|
||||||
song_id: &uuid::Uuid,
|
|
||||||
coverart_id: &uuid::Uuid,
|
|
||||||
) -> Result<axum::response::Response, std::convert::Infallible> {
|
|
||||||
let payload = serde_json::json!({
|
|
||||||
"song_id": song_id,
|
|
||||||
"coverart_queue_id": coverart_id
|
|
||||||
});
|
|
||||||
let req = axum::http::Request::builder()
|
|
||||||
.method(axum::http::Method::POST)
|
|
||||||
.uri(crate::callers::endpoints::CREATECOVERART)
|
|
||||||
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
|
||||||
.header(axum::http::header::AUTHORIZATION, bearer_auth().await)
|
|
||||||
.body(axum::body::Body::from(payload.to_string()))
|
|
||||||
.unwrap();
|
|
||||||
app.clone().oneshot(req).await
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn create_song_req(
|
pub async fn fetch_queue_req(
|
||||||
app: &axum::Router,
|
app: &axum::Router,
|
||||||
song_queue_id: &uuid::Uuid,
|
) -> Result<axum::response::Response, std::convert::Infallible> {
|
||||||
user_id: &uuid::Uuid,
|
let fetch_req = axum::http::Request::builder()
|
||||||
) -> Result<axum::response::Response, std::convert::Infallible> {
|
.method(axum::http::Method::GET)
|
||||||
let payload = payload_data::create_song(song_queue_id, user_id).await;
|
.uri(crate::callers::queue::endpoints::NEXTQUEUESONG)
|
||||||
|
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
||||||
|
.header(
|
||||||
|
axum::http::header::AUTHORIZATION,
|
||||||
|
super::bearer_auth().await,
|
||||||
|
)
|
||||||
|
.body(axum::body::Body::empty())
|
||||||
|
.unwrap();
|
||||||
|
app.clone().oneshot(fetch_req).await
|
||||||
|
}
|
||||||
|
|
||||||
let req = axum::http::Request::builder()
|
pub async fn fetch_metadata_queue_req(
|
||||||
.method(axum::http::Method::POST)
|
app: &axum::Router,
|
||||||
.uri(crate::callers::endpoints::CREATESONG)
|
id: &uuid::Uuid,
|
||||||
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
) -> Result<axum::response::Response, std::convert::Infallible> {
|
||||||
.header(axum::http::header::AUTHORIZATION, bearer_auth().await)
|
let uri = format!(
|
||||||
.body(axum::body::Body::from(payload.to_string()))
|
"{}?id={}",
|
||||||
.unwrap();
|
crate::callers::queue::endpoints::QUEUEMETADATA,
|
||||||
|
id
|
||||||
|
);
|
||||||
|
|
||||||
app.clone().oneshot(req).await
|
let req = axum::http::Request::builder()
|
||||||
}
|
.method(axum::http::Method::GET)
|
||||||
|
.uri(uri)
|
||||||
|
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
||||||
|
.header(
|
||||||
|
axum::http::header::AUTHORIZATION,
|
||||||
|
super::bearer_auth().await,
|
||||||
|
)
|
||||||
|
.body(axum::body::Body::empty())
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
async fn update_song_queue_status_req(
|
app.clone().oneshot(req).await
|
||||||
app: &axum::Router,
|
}
|
||||||
song_queue_id: &uuid::Uuid,
|
|
||||||
) -> Result<axum::response::Response, std::convert::Infallible> {
|
|
||||||
let payload = serde_json::json!({
|
|
||||||
"id": &song_queue_id,
|
|
||||||
"status": crate::repo::queue::song::status::READY
|
|
||||||
});
|
|
||||||
|
|
||||||
let req = axum::http::Request::builder()
|
pub async fn fetch_queue_data_req(
|
||||||
.method(axum::http::Method::PATCH)
|
app: &axum::Router,
|
||||||
.uri(crate::callers::queue::endpoints::QUEUESONG)
|
id: &uuid::Uuid,
|
||||||
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
) -> Result<axum::response::Response, std::convert::Infallible> {
|
||||||
.header(axum::http::header::AUTHORIZATION, bearer_auth().await)
|
let raw_uri = String::from(crate::callers::queue::endpoints::QUEUESONGDATA);
|
||||||
.body(axum::body::Body::from(payload.to_string()))
|
let end_index = raw_uri.len() - 4;
|
||||||
.unwrap();
|
let mut uri: String = (&raw_uri[..end_index]).to_string();
|
||||||
|
uri += &id.to_string();
|
||||||
|
let req = axum::http::Request::builder()
|
||||||
|
.method(axum::http::Method::GET)
|
||||||
|
.uri(uri)
|
||||||
|
.header(
|
||||||
|
axum::http::header::CONTENT_TYPE,
|
||||||
|
icarus_meta::detection::song::constants::mime::FLAC,
|
||||||
|
)
|
||||||
|
.header(
|
||||||
|
axum::http::header::AUTHORIZATION,
|
||||||
|
super::bearer_auth().await,
|
||||||
|
)
|
||||||
|
.body(axum::body::Body::empty())
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
app.clone().oneshot(req).await
|
app.clone().oneshot(req).await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_queued_coverart(
|
pub async fn upload_coverart_queue_req(
|
||||||
app: &axum::Router,
|
app: &axum::Router,
|
||||||
coverart_queue_id: &uuid::Uuid,
|
) -> Result<axum::response::Response, std::convert::Infallible> {
|
||||||
) -> Result<axum::response::Response, std::convert::Infallible> {
|
let mut form = MultipartForm::default();
|
||||||
let uri = format!(
|
let _ = form.add_file(
|
||||||
"{}?id={}",
|
icarus_meta::detection::coverart::constants::JPEG_TYPE,
|
||||||
crate::callers::queue::endpoints::QUEUECOVERART,
|
"tests/I/Coverart-1.jpg",
|
||||||
coverart_queue_id
|
);
|
||||||
);
|
|
||||||
|
|
||||||
let req = axum::http::Request::builder()
|
// Create request
|
||||||
.method(axum::http::Method::GET)
|
let content_type = form.content_type();
|
||||||
.uri(uri)
|
let body = MultipartBody::from(form);
|
||||||
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
|
||||||
.header(axum::http::header::AUTHORIZATION, bearer_auth().await)
|
|
||||||
.body(axum::body::Body::empty())
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
app.clone().oneshot(req).await
|
let req = axum::http::Request::builder()
|
||||||
|
.method(axum::http::Method::POST)
|
||||||
|
.uri(crate::callers::queue::endpoints::QUEUECOVERART)
|
||||||
|
.header(axum::http::header::CONTENT_TYPE, content_type)
|
||||||
|
.header(
|
||||||
|
axum::http::header::AUTHORIZATION,
|
||||||
|
super::bearer_auth().await,
|
||||||
|
)
|
||||||
|
.body(axum::body::Body::from_stream(body))
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
app.clone().oneshot(req).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn queue_metadata_req(
|
||||||
|
app: &axum::Router,
|
||||||
|
song_queue_id: &uuid::Uuid,
|
||||||
|
) -> Result<axum::response::Response, std::convert::Infallible> {
|
||||||
|
let payload = super::payload_data::queue_metadata_payload_data(&song_queue_id).await;
|
||||||
|
|
||||||
|
let req = axum::http::Request::builder()
|
||||||
|
.method(axum::http::Method::POST)
|
||||||
|
.uri(crate::callers::queue::endpoints::QUEUEMETADATA)
|
||||||
|
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
||||||
|
.header(
|
||||||
|
axum::http::header::AUTHORIZATION,
|
||||||
|
super::bearer_auth().await,
|
||||||
|
)
|
||||||
|
.body(axum::body::Body::from(payload.to_string()))
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
app.clone().oneshot(req).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn coverart_queue_song_queue_link_req(
|
||||||
|
app: &axum::Router,
|
||||||
|
coverart_id: &uuid::Uuid,
|
||||||
|
song_queue_id: &uuid::Uuid,
|
||||||
|
) -> Result<axum::response::Response, std::convert::Infallible> {
|
||||||
|
let payload = serde_json::json!(
|
||||||
|
{
|
||||||
|
"song_queue_id": song_queue_id,
|
||||||
|
"coverart_id" : coverart_id,
|
||||||
|
});
|
||||||
|
let req = axum::http::Request::builder()
|
||||||
|
.method(axum::http::Method::PATCH)
|
||||||
|
.uri(crate::callers::queue::endpoints::QUEUECOVERARTLINK)
|
||||||
|
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
||||||
|
.header(
|
||||||
|
axum::http::header::AUTHORIZATION,
|
||||||
|
super::bearer_auth().await,
|
||||||
|
)
|
||||||
|
.body(axum::body::Body::from(payload.to_string()))
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
app.clone().oneshot(req).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn create_coverart_req(
|
||||||
|
app: &axum::Router,
|
||||||
|
song_id: &uuid::Uuid,
|
||||||
|
coverart_id: &uuid::Uuid,
|
||||||
|
) -> Result<axum::response::Response, std::convert::Infallible> {
|
||||||
|
let payload = serde_json::json!({
|
||||||
|
"song_id": song_id,
|
||||||
|
"coverart_queue_id": coverart_id
|
||||||
|
});
|
||||||
|
let req = axum::http::Request::builder()
|
||||||
|
.method(axum::http::Method::POST)
|
||||||
|
.uri(crate::callers::endpoints::CREATECOVERART)
|
||||||
|
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
||||||
|
.header(
|
||||||
|
axum::http::header::AUTHORIZATION,
|
||||||
|
super::bearer_auth().await,
|
||||||
|
)
|
||||||
|
.body(axum::body::Body::from(payload.to_string()))
|
||||||
|
.unwrap();
|
||||||
|
app.clone().oneshot(req).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn create_song_req(
|
||||||
|
app: &axum::Router,
|
||||||
|
song_queue_id: &uuid::Uuid,
|
||||||
|
user_id: &uuid::Uuid,
|
||||||
|
) -> Result<axum::response::Response, std::convert::Infallible> {
|
||||||
|
let payload = super::payload_data::create_song(song_queue_id, user_id).await;
|
||||||
|
|
||||||
|
let req = axum::http::Request::builder()
|
||||||
|
.method(axum::http::Method::POST)
|
||||||
|
.uri(crate::callers::endpoints::CREATESONG)
|
||||||
|
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
||||||
|
.header(
|
||||||
|
axum::http::header::AUTHORIZATION,
|
||||||
|
super::bearer_auth().await,
|
||||||
|
)
|
||||||
|
.body(axum::body::Body::from(payload.to_string()))
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
app.clone().oneshot(req).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn update_song_queue_status_req(
|
||||||
|
app: &axum::Router,
|
||||||
|
song_queue_id: &uuid::Uuid,
|
||||||
|
) -> Result<axum::response::Response, std::convert::Infallible> {
|
||||||
|
let payload = serde_json::json!({
|
||||||
|
"id": &song_queue_id,
|
||||||
|
"status": crate::repo::queue::song::status::READY
|
||||||
|
});
|
||||||
|
|
||||||
|
let req = axum::http::Request::builder()
|
||||||
|
.method(axum::http::Method::PATCH)
|
||||||
|
.uri(crate::callers::queue::endpoints::QUEUESONG)
|
||||||
|
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
||||||
|
.header(
|
||||||
|
axum::http::header::AUTHORIZATION,
|
||||||
|
super::bearer_auth().await,
|
||||||
|
)
|
||||||
|
.body(axum::body::Body::from(payload.to_string()))
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
app.clone().oneshot(req).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_queued_coverart(
|
||||||
|
app: &axum::Router,
|
||||||
|
coverart_queue_id: &uuid::Uuid,
|
||||||
|
) -> Result<axum::response::Response, std::convert::Infallible> {
|
||||||
|
let uri = format!(
|
||||||
|
"{}?id={}",
|
||||||
|
crate::callers::queue::endpoints::QUEUECOVERART,
|
||||||
|
coverart_queue_id
|
||||||
|
);
|
||||||
|
|
||||||
|
let req = axum::http::Request::builder()
|
||||||
|
.method(axum::http::Method::GET)
|
||||||
|
.uri(uri)
|
||||||
|
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
||||||
|
.header(
|
||||||
|
axum::http::header::AUTHORIZATION,
|
||||||
|
super::bearer_auth().await,
|
||||||
|
)
|
||||||
|
.body(axum::body::Body::empty())
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
app.clone().oneshot(req).await
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod sequence_flow {
|
mod sequence_flow {
|
||||||
@@ -700,7 +748,7 @@ mod tests {
|
|||||||
pub async fn queue_song_flow(
|
pub async fn queue_song_flow(
|
||||||
app: &axum::Router,
|
app: &axum::Router,
|
||||||
) -> Result<(axum::response::Response, uuid::Uuid), std::convert::Infallible> {
|
) -> Result<(axum::response::Response, uuid::Uuid), std::convert::Infallible> {
|
||||||
match super::song_queue_req(&app).await {
|
match super::request::song_queue_req(&app).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
let resp = super::util::get_resp_data::<
|
let resp = super::util::get_resp_data::<
|
||||||
crate::callers::queue::song::response::song_queue::Response,
|
crate::callers::queue::song::response::song_queue::Response,
|
||||||
@@ -713,7 +761,8 @@ mod tests {
|
|||||||
|
|
||||||
let user_id = super::TEST_USER_ID;
|
let user_id = super::TEST_USER_ID;
|
||||||
|
|
||||||
match super::song_queue_link_req(&app, &song_queue_id, &user_id).await {
|
match super::request::song_queue_link_req(&app, &song_queue_id, &user_id).await
|
||||||
|
{
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
let resp = super::util::get_resp_data::<
|
let resp = super::util::get_resp_data::<
|
||||||
crate::callers::queue::song::response::link_user_id::Response,
|
crate::callers::queue::song::response::link_user_id::Response,
|
||||||
@@ -725,7 +774,7 @@ mod tests {
|
|||||||
"The response should not be empty"
|
"The response should not be empty"
|
||||||
);
|
);
|
||||||
|
|
||||||
match super::queue_metadata_req(&app, &song_queue_id).await {
|
match super::request::queue_metadata_req(&app, &song_queue_id).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
let resp = super::util::get_resp_data::<
|
let resp = super::util::get_resp_data::<
|
||||||
crate::callers::queue::song::response::song_queue::Response,
|
crate::callers::queue::song::response::song_queue::Response,
|
||||||
@@ -735,7 +784,8 @@ mod tests {
|
|||||||
|
|
||||||
let id = resp.data[0];
|
let id = resp.data[0];
|
||||||
|
|
||||||
match super::fetch_metadata_queue_req(&app, &id).await {
|
match super::request::fetch_metadata_queue_req(&app, &id).await
|
||||||
|
{
|
||||||
Ok(response) => Ok((response, user_id)),
|
Ok(response) => Ok((response, user_id)),
|
||||||
Err(err) => Err(err),
|
Err(err) => Err(err),
|
||||||
}
|
}
|
||||||
@@ -754,7 +804,7 @@ mod tests {
|
|||||||
app: &axum::Router,
|
app: &axum::Router,
|
||||||
song_queue_id: &uuid::Uuid,
|
song_queue_id: &uuid::Uuid,
|
||||||
) -> Result<axum::response::Response, std::convert::Infallible> {
|
) -> Result<axum::response::Response, std::convert::Infallible> {
|
||||||
match super::upload_coverart_queue_req(&app).await {
|
match super::request::upload_coverart_queue_req(&app).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
let resp = super::util::get_resp_data::<
|
let resp = super::util::get_resp_data::<
|
||||||
crate::callers::queue::coverart::response::queue::Response,
|
crate::callers::queue::coverart::response::queue::Response,
|
||||||
@@ -764,7 +814,7 @@ mod tests {
|
|||||||
let coverart_id = resp.data[0];
|
let coverart_id = resp.data[0];
|
||||||
assert_eq!(false, coverart_id.is_nil(), "Should not be empty");
|
assert_eq!(false, coverart_id.is_nil(), "Should not be empty");
|
||||||
|
|
||||||
match super::coverart_queue_song_queue_link_req(
|
match super::request::coverart_queue_song_queue_link_req(
|
||||||
&app,
|
&app,
|
||||||
&coverart_id,
|
&coverart_id,
|
||||||
&song_queue_id,
|
&song_queue_id,
|
||||||
@@ -783,7 +833,8 @@ mod tests {
|
|||||||
assert_eq!(false, resp_coverart_id.is_nil(), "Should not be empty");
|
assert_eq!(false, resp_coverart_id.is_nil(), "Should not be empty");
|
||||||
assert_eq!(false, resp_song_queue_id.is_nil(), "Should not be empty");
|
assert_eq!(false, resp_song_queue_id.is_nil(), "Should not be empty");
|
||||||
|
|
||||||
match super::get_queued_coverart(&app, &resp_coverart_id).await {
|
match super::request::get_queued_coverart(&app, &resp_coverart_id).await
|
||||||
|
{
|
||||||
Ok(response) => Ok(response),
|
Ok(response) => Ok(response),
|
||||||
Err(err) => Err(err),
|
Err(err) => Err(err),
|
||||||
}
|
}
|
||||||
@@ -806,7 +857,7 @@ mod tests {
|
|||||||
assert_eq!(false, resp.data.is_empty(), "Data should not be empty");
|
assert_eq!(false, resp.data.is_empty(), "Data should not be empty");
|
||||||
let song_queue_id = resp.data[0].song_queue_id;
|
let song_queue_id = resp.data[0].song_queue_id;
|
||||||
|
|
||||||
match super::create_song_req(&app, &song_queue_id, &user_id).await {
|
match super::request::create_song_req(&app, &song_queue_id, &user_id).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
let resp = super::util::get_resp_data::<
|
let resp = super::util::get_resp_data::<
|
||||||
crate::callers::song::response::create_metadata::Response,
|
crate::callers::song::response::create_metadata::Response,
|
||||||
@@ -914,7 +965,7 @@ mod tests {
|
|||||||
let app = init::app(pool).await;
|
let app = init::app(pool).await;
|
||||||
|
|
||||||
// Send request
|
// Send request
|
||||||
match song_queue_req(&app).await {
|
match request::song_queue_req(&app).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
let resp = util::get_resp_data::<
|
let resp = util::get_resp_data::<
|
||||||
crate::callers::queue::song::response::song_queue::Response,
|
crate::callers::queue::song::response::song_queue::Response,
|
||||||
@@ -950,7 +1001,7 @@ mod tests {
|
|||||||
|
|
||||||
let app = init::app(pool).await;
|
let app = init::app(pool).await;
|
||||||
|
|
||||||
match song_queue_req(&app).await {
|
match request::song_queue_req(&app).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
let resp = util::get_resp_data::<
|
let resp = util::get_resp_data::<
|
||||||
crate::callers::queue::song::response::song_queue::Response,
|
crate::callers::queue::song::response::song_queue::Response,
|
||||||
@@ -963,7 +1014,7 @@ mod tests {
|
|||||||
let user_id = TEST_USER_ID;
|
let user_id = TEST_USER_ID;
|
||||||
println!("User Id: {user_id:?}");
|
println!("User Id: {user_id:?}");
|
||||||
|
|
||||||
match song_queue_link_req(&app, &song_queue_id, &user_id).await {
|
match request::song_queue_link_req(&app, &song_queue_id, &user_id).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
let resp = util::get_resp_data::<
|
let resp = util::get_resp_data::<
|
||||||
crate::callers::queue::song::response::link_user_id::Response,
|
crate::callers::queue::song::response::link_user_id::Response,
|
||||||
@@ -1028,7 +1079,7 @@ mod tests {
|
|||||||
let old = crate::repo::queue::song::status::PENDING;
|
let old = crate::repo::queue::song::status::PENDING;
|
||||||
let target_status = crate::repo::queue::song::status::READY;
|
let target_status = crate::repo::queue::song::status::READY;
|
||||||
|
|
||||||
match update_song_queue_status_req(&app, &song_queue_id).await {
|
match request::update_song_queue_status_req(&app, &song_queue_id).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
let resp = util::get_resp_data::<
|
let resp = util::get_resp_data::<
|
||||||
crate::callers::queue::song::response::update_status::Response,
|
crate::callers::queue::song::response::update_status::Response,
|
||||||
@@ -1043,7 +1094,7 @@ mod tests {
|
|||||||
"New status does not match"
|
"New status does not match"
|
||||||
);
|
);
|
||||||
|
|
||||||
match fetch_queue_req(&app).await {
|
match request::fetch_queue_req(&app).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
let resp = util::get_resp_data::<
|
let resp = util::get_resp_data::<
|
||||||
crate::callers::queue::song::response::fetch_queue_song::Response,
|
crate::callers::queue::song::response::fetch_queue_song::Response,
|
||||||
@@ -1089,7 +1140,7 @@ mod tests {
|
|||||||
let app = init::app(pool).await;
|
let app = init::app(pool).await;
|
||||||
|
|
||||||
// Send request
|
// Send request
|
||||||
match song_queue_req(&app).await {
|
match request::song_queue_req(&app).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
let resp = util::get_resp_data::<
|
let resp = util::get_resp_data::<
|
||||||
crate::callers::queue::song::response::song_queue::Response,
|
crate::callers::queue::song::response::song_queue::Response,
|
||||||
@@ -1100,7 +1151,7 @@ mod tests {
|
|||||||
|
|
||||||
let id = &resp.data[0];
|
let id = &resp.data[0];
|
||||||
|
|
||||||
match fetch_queue_data_req(&app, &id).await {
|
match request::fetch_queue_data_req(&app, &id).await {
|
||||||
Ok(response) => match util::resp_to_bytes(response).await {
|
Ok(response) => match util::resp_to_bytes(response).await {
|
||||||
Ok(bytes) => {
|
Ok(bytes) => {
|
||||||
assert_eq!(false, bytes.is_empty(), "Queued data should not be empty");
|
assert_eq!(false, bytes.is_empty(), "Queued data should not be empty");
|
||||||
@@ -1215,7 +1266,7 @@ mod tests {
|
|||||||
let app = init::app(pool).await;
|
let app = init::app(pool).await;
|
||||||
|
|
||||||
// Send request
|
// Send request
|
||||||
match song_queue_req(&app).await {
|
match request::song_queue_req(&app).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
let resp = util::get_resp_data::<
|
let resp = util::get_resp_data::<
|
||||||
crate::callers::queue::song::response::song_queue::Response,
|
crate::callers::queue::song::response::song_queue::Response,
|
||||||
@@ -1225,7 +1276,7 @@ mod tests {
|
|||||||
assert_eq!(false, resp.data[0].is_nil(), "Should not be empty");
|
assert_eq!(false, resp.data[0].is_nil(), "Should not be empty");
|
||||||
let id = resp.data[0];
|
let id = resp.data[0];
|
||||||
|
|
||||||
match fetch_queue_data_req(&app, &id).await {
|
match request::fetch_queue_data_req(&app, &id).await {
|
||||||
Ok(response) => match util::resp_to_bytes(response).await {
|
Ok(response) => match util::resp_to_bytes(response).await {
|
||||||
Ok(bytes) => {
|
Ok(bytes) => {
|
||||||
assert_eq!(false, bytes.is_empty(), "Queued data should not be empty");
|
assert_eq!(false, bytes.is_empty(), "Queued data should not be empty");
|
||||||
@@ -1279,7 +1330,7 @@ mod tests {
|
|||||||
let old = crate::repo::queue::song::status::PENDING;
|
let old = crate::repo::queue::song::status::PENDING;
|
||||||
let done = crate::repo::queue::song::status::READY;
|
let done = crate::repo::queue::song::status::READY;
|
||||||
|
|
||||||
match update_song_queue_status_req(&app, &song_queue_id).await {
|
match request::update_song_queue_status_req(&app, &song_queue_id).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
let resp = util::get_resp_data::<
|
let resp = util::get_resp_data::<
|
||||||
crate::callers::queue::song::response::update_status::Response,
|
crate::callers::queue::song::response::update_status::Response,
|
||||||
@@ -1324,7 +1375,7 @@ mod tests {
|
|||||||
let app = init::app(pool).await;
|
let app = init::app(pool).await;
|
||||||
|
|
||||||
// Send request
|
// Send request
|
||||||
match song_queue_req(&app).await {
|
match request::song_queue_req(&app).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
let resp = util::get_resp_data::<
|
let resp = util::get_resp_data::<
|
||||||
crate::callers::queue::song::response::song_queue::Response,
|
crate::callers::queue::song::response::song_queue::Response,
|
||||||
@@ -1333,7 +1384,7 @@ mod tests {
|
|||||||
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||||
assert_eq!(false, resp.data[0].is_nil(), "Should not be empty");
|
assert_eq!(false, resp.data[0].is_nil(), "Should not be empty");
|
||||||
|
|
||||||
match queue_metadata_req(&app, &resp.data[0]).await {
|
match request::queue_metadata_req(&app, &resp.data[0]).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
let resp = util::get_resp_data::<
|
let resp = util::get_resp_data::<
|
||||||
crate::callers::queue::song::response::song_queue::Response,
|
crate::callers::queue::song::response::song_queue::Response,
|
||||||
@@ -1410,7 +1461,7 @@ mod tests {
|
|||||||
let app = init::app(pool).await;
|
let app = init::app(pool).await;
|
||||||
|
|
||||||
// Send request
|
// Send request
|
||||||
match upload_coverart_queue_req(&app).await {
|
match request::upload_coverart_queue_req(&app).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
let resp = util::get_resp_data::<
|
let resp = util::get_resp_data::<
|
||||||
crate::callers::queue::coverart::response::queue::Response,
|
crate::callers::queue::coverart::response::queue::Response,
|
||||||
@@ -1447,7 +1498,7 @@ mod tests {
|
|||||||
|
|
||||||
let app = init::app(pool).await;
|
let app = init::app(pool).await;
|
||||||
|
|
||||||
match song_queue_req(&app).await {
|
match request::song_queue_req(&app).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
let resp = util::get_resp_data::<
|
let resp = util::get_resp_data::<
|
||||||
crate::callers::queue::coverart::response::queue::Response,
|
crate::callers::queue::coverart::response::queue::Response,
|
||||||
@@ -1458,7 +1509,7 @@ mod tests {
|
|||||||
assert_eq!(false, song_queue_id.is_nil(), "Should not be empty");
|
assert_eq!(false, song_queue_id.is_nil(), "Should not be empty");
|
||||||
|
|
||||||
// Send request
|
// Send request
|
||||||
match upload_coverart_queue_req(&app).await {
|
match request::upload_coverart_queue_req(&app).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
let resp = util::get_resp_data::<
|
let resp = util::get_resp_data::<
|
||||||
crate::callers::queue::coverart::response::queue::Response,
|
crate::callers::queue::coverart::response::queue::Response,
|
||||||
@@ -1468,8 +1519,12 @@ mod tests {
|
|||||||
let coverart_id = resp.data[0];
|
let coverart_id = resp.data[0];
|
||||||
assert_eq!(false, coverart_id.is_nil(), "Should not be empty");
|
assert_eq!(false, coverart_id.is_nil(), "Should not be empty");
|
||||||
|
|
||||||
match coverart_queue_song_queue_link_req(&app, &coverart_id, &song_queue_id)
|
match request::coverart_queue_song_queue_link_req(
|
||||||
.await
|
&app,
|
||||||
|
&coverart_id,
|
||||||
|
&song_queue_id,
|
||||||
|
)
|
||||||
|
.await
|
||||||
{
|
{
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
let resp = util::get_resp_data::<
|
let resp = util::get_resp_data::<
|
||||||
@@ -1524,7 +1579,7 @@ mod tests {
|
|||||||
|
|
||||||
let app = init::app(pool).await;
|
let app = init::app(pool).await;
|
||||||
|
|
||||||
match song_queue_req(&app).await {
|
match request::song_queue_req(&app).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
let resp = util::get_resp_data::<
|
let resp = util::get_resp_data::<
|
||||||
crate::callers::queue::coverart::response::queue::Response,
|
crate::callers::queue::coverart::response::queue::Response,
|
||||||
@@ -1574,7 +1629,7 @@ mod tests {
|
|||||||
|
|
||||||
let app = init::app(pool).await;
|
let app = init::app(pool).await;
|
||||||
|
|
||||||
match song_queue_req(&app).await {
|
match request::song_queue_req(&app).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
let resp = util::get_resp_data::<
|
let resp = util::get_resp_data::<
|
||||||
crate::callers::queue::coverart::response::queue::Response,
|
crate::callers::queue::coverart::response::queue::Response,
|
||||||
@@ -1585,7 +1640,7 @@ mod tests {
|
|||||||
assert_eq!(false, song_queue_id.is_nil(), "Should not be empty");
|
assert_eq!(false, song_queue_id.is_nil(), "Should not be empty");
|
||||||
|
|
||||||
// Send request
|
// Send request
|
||||||
match upload_coverart_queue_req(&app).await {
|
match request::upload_coverart_queue_req(&app).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
let resp = util::get_resp_data::<
|
let resp = util::get_resp_data::<
|
||||||
crate::callers::queue::coverart::response::queue::Response,
|
crate::callers::queue::coverart::response::queue::Response,
|
||||||
@@ -1595,8 +1650,12 @@ mod tests {
|
|||||||
let coverart_id = resp.data[0];
|
let coverart_id = resp.data[0];
|
||||||
assert_eq!(false, coverart_id.is_nil(), "Should not be empty");
|
assert_eq!(false, coverart_id.is_nil(), "Should not be empty");
|
||||||
|
|
||||||
match coverart_queue_song_queue_link_req(&app, &coverart_id, &song_queue_id)
|
match request::coverart_queue_song_queue_link_req(
|
||||||
.await
|
&app,
|
||||||
|
&coverart_id,
|
||||||
|
&song_queue_id,
|
||||||
|
)
|
||||||
|
.await
|
||||||
{
|
{
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
let resp = util::get_resp_data::<
|
let resp = util::get_resp_data::<
|
||||||
@@ -1714,7 +1773,7 @@ mod tests {
|
|||||||
assert_eq!(false, resp.data.is_empty(), "Data should not be empty");
|
assert_eq!(false, resp.data.is_empty(), "Data should not be empty");
|
||||||
let song_q_id = resp.data[0].song_queue_id;
|
let song_q_id = resp.data[0].song_queue_id;
|
||||||
|
|
||||||
match create_song_req(&app, &song_q_id, &user_id).await {
|
match request::create_song_req(&app, &song_q_id, &user_id).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
let resp = util::get_resp_data::<
|
let resp = util::get_resp_data::<
|
||||||
crate::callers::song::response::create_metadata::Response,
|
crate::callers::song::response::create_metadata::Response,
|
||||||
@@ -1777,7 +1836,7 @@ mod tests {
|
|||||||
assert_eq!(false, resp.data.is_empty(), "Data should not be empty");
|
assert_eq!(false, resp.data.is_empty(), "Data should not be empty");
|
||||||
let song_queue_id = resp.data[0].song_queue_id;
|
let song_queue_id = resp.data[0].song_queue_id;
|
||||||
|
|
||||||
match create_song_req(&app, &song_queue_id, &user_id).await {
|
match request::create_song_req(&app, &song_queue_id, &user_id).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
let resp = util::get_resp_data::<
|
let resp = util::get_resp_data::<
|
||||||
crate::callers::song::response::create_metadata::Response,
|
crate::callers::song::response::create_metadata::Response,
|
||||||
@@ -1807,8 +1866,12 @@ mod tests {
|
|||||||
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||||
let resp_queue_coverart_id = resp.data[0].id;
|
let resp_queue_coverart_id = resp.data[0].id;
|
||||||
|
|
||||||
match create_coverart_req(&app, &song_id, &resp_queue_coverart_id)
|
match request::create_coverart_req(
|
||||||
.await
|
&app,
|
||||||
|
&song_id,
|
||||||
|
&resp_queue_coverart_id,
|
||||||
|
)
|
||||||
|
.await
|
||||||
{
|
{
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
let resp = util::get_resp_data::<
|
let resp = util::get_resp_data::<
|
||||||
@@ -1870,7 +1933,7 @@ mod tests {
|
|||||||
assert_eq!(false, resp.data.is_empty(), "Data should not be empty");
|
assert_eq!(false, resp.data.is_empty(), "Data should not be empty");
|
||||||
let song_q_id = resp.data[0].song_queue_id;
|
let song_q_id = resp.data[0].song_queue_id;
|
||||||
|
|
||||||
match create_song_req(&app, &song_q_id, &user_id).await {
|
match request::create_song_req(&app, &song_q_id, &user_id).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
let resp = util::get_resp_data::<
|
let resp = util::get_resp_data::<
|
||||||
crate::callers::song::response::create_metadata::Response,
|
crate::callers::song::response::create_metadata::Response,
|
||||||
@@ -1976,7 +2039,7 @@ mod tests {
|
|||||||
assert_eq!(false, resp.data.is_empty(), "Data should not be empty");
|
assert_eq!(false, resp.data.is_empty(), "Data should not be empty");
|
||||||
let song_queue_id = resp.data[0].song_queue_id;
|
let song_queue_id = resp.data[0].song_queue_id;
|
||||||
|
|
||||||
match create_song_req(&app, &song_queue_id, &user_id).await {
|
match request::create_song_req(&app, &song_queue_id, &user_id).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
let resp = util::get_resp_data::<
|
let resp = util::get_resp_data::<
|
||||||
crate::callers::song::response::create_metadata::Response,
|
crate::callers::song::response::create_metadata::Response,
|
||||||
|
|||||||
Reference in New Issue
Block a user