tsk-206: Moving request functions to their own module in testing
This commit is contained in:
+55
-46
@@ -463,8 +463,14 @@ 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::{
|
||||||
|
Body as MultipartBody, Form as MultipartForm,
|
||||||
|
};
|
||||||
|
use tower::ServiceExt;
|
||||||
|
|
||||||
|
|
||||||
|
pub async fn song_queue_req(
|
||||||
app: &axum::Router,
|
app: &axum::Router,
|
||||||
) -> Result<axum::response::Response, std::convert::Infallible> {
|
) -> Result<axum::response::Response, std::convert::Infallible> {
|
||||||
// Create multipart form
|
// Create multipart form
|
||||||
@@ -478,13 +484,13 @@ mod tests {
|
|||||||
.method(axum::http::Method::POST)
|
.method(axum::http::Method::POST)
|
||||||
.uri(crate::callers::queue::endpoints::QUEUESONG)
|
.uri(crate::callers::queue::endpoints::QUEUESONG)
|
||||||
.header(axum::http::header::CONTENT_TYPE, content_type)
|
.header(axum::http::header::CONTENT_TYPE, content_type)
|
||||||
.header(axum::http::header::AUTHORIZATION, bearer_auth().await)
|
.header(axum::http::header::AUTHORIZATION, super::bearer_auth().await)
|
||||||
.body(axum::body::Body::from_stream(body))
|
.body(axum::body::Body::from_stream(body))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
app.clone().oneshot(req).await
|
app.clone().oneshot(req).await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn song_queue_link_req(
|
pub async fn song_queue_link_req(
|
||||||
app: &axum::Router,
|
app: &axum::Router,
|
||||||
song_queue_id: &uuid::Uuid,
|
song_queue_id: &uuid::Uuid,
|
||||||
user_id: &uuid::Uuid,
|
user_id: &uuid::Uuid,
|
||||||
@@ -498,27 +504,27 @@ mod tests {
|
|||||||
.method(axum::http::Method::PATCH)
|
.method(axum::http::Method::PATCH)
|
||||||
.uri(crate::callers::queue::endpoints::QUEUESONGLINKUSERID)
|
.uri(crate::callers::queue::endpoints::QUEUESONGLINKUSERID)
|
||||||
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
||||||
.header(axum::http::header::AUTHORIZATION, bearer_auth().await)
|
.header(axum::http::header::AUTHORIZATION, super::bearer_auth().await)
|
||||||
.body(axum::body::Body::from(payload.to_string()))
|
.body(axum::body::Body::from(payload.to_string()))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
app.clone().oneshot(req).await
|
app.clone().oneshot(req).await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn fetch_queue_req(
|
pub async fn fetch_queue_req(
|
||||||
app: &axum::Router,
|
app: &axum::Router,
|
||||||
) -> Result<axum::response::Response, std::convert::Infallible> {
|
) -> Result<axum::response::Response, std::convert::Infallible> {
|
||||||
let fetch_req = axum::http::Request::builder()
|
let fetch_req = axum::http::Request::builder()
|
||||||
.method(axum::http::Method::GET)
|
.method(axum::http::Method::GET)
|
||||||
.uri(crate::callers::queue::endpoints::NEXTQUEUESONG)
|
.uri(crate::callers::queue::endpoints::NEXTQUEUESONG)
|
||||||
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
||||||
.header(axum::http::header::AUTHORIZATION, bearer_auth().await)
|
.header(axum::http::header::AUTHORIZATION, super::bearer_auth().await)
|
||||||
.body(axum::body::Body::empty())
|
.body(axum::body::Body::empty())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
app.clone().oneshot(fetch_req).await
|
app.clone().oneshot(fetch_req).await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn fetch_metadata_queue_req(
|
pub async fn fetch_metadata_queue_req(
|
||||||
app: &axum::Router,
|
app: &axum::Router,
|
||||||
id: &uuid::Uuid,
|
id: &uuid::Uuid,
|
||||||
) -> Result<axum::response::Response, std::convert::Infallible> {
|
) -> Result<axum::response::Response, std::convert::Infallible> {
|
||||||
@@ -532,14 +538,14 @@ mod tests {
|
|||||||
.method(axum::http::Method::GET)
|
.method(axum::http::Method::GET)
|
||||||
.uri(uri)
|
.uri(uri)
|
||||||
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
||||||
.header(axum::http::header::AUTHORIZATION, bearer_auth().await)
|
.header(axum::http::header::AUTHORIZATION, super::bearer_auth().await)
|
||||||
.body(axum::body::Body::empty())
|
.body(axum::body::Body::empty())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
app.clone().oneshot(req).await
|
app.clone().oneshot(req).await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn fetch_queue_data_req(
|
pub async fn fetch_queue_data_req(
|
||||||
app: &axum::Router,
|
app: &axum::Router,
|
||||||
id: &uuid::Uuid,
|
id: &uuid::Uuid,
|
||||||
) -> Result<axum::response::Response, std::convert::Infallible> {
|
) -> Result<axum::response::Response, std::convert::Infallible> {
|
||||||
@@ -551,14 +557,14 @@ mod tests {
|
|||||||
.method(axum::http::Method::GET)
|
.method(axum::http::Method::GET)
|
||||||
.uri(uri)
|
.uri(uri)
|
||||||
.header(axum::http::header::CONTENT_TYPE, "audio/flac")
|
.header(axum::http::header::CONTENT_TYPE, "audio/flac")
|
||||||
.header(axum::http::header::AUTHORIZATION, bearer_auth().await)
|
.header(axum::http::header::AUTHORIZATION, super::bearer_auth().await)
|
||||||
.body(axum::body::Body::empty())
|
.body(axum::body::Body::empty())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
app.clone().oneshot(req).await
|
app.clone().oneshot(req).await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn upload_coverart_queue_req(
|
pub async fn upload_coverart_queue_req(
|
||||||
app: &axum::Router,
|
app: &axum::Router,
|
||||||
) -> Result<axum::response::Response, std::convert::Infallible> {
|
) -> Result<axum::response::Response, std::convert::Infallible> {
|
||||||
let mut form = MultipartForm::default();
|
let mut form = MultipartForm::default();
|
||||||
@@ -572,31 +578,31 @@ mod tests {
|
|||||||
.method(axum::http::Method::POST)
|
.method(axum::http::Method::POST)
|
||||||
.uri(crate::callers::queue::endpoints::QUEUECOVERART)
|
.uri(crate::callers::queue::endpoints::QUEUECOVERART)
|
||||||
.header(axum::http::header::CONTENT_TYPE, content_type)
|
.header(axum::http::header::CONTENT_TYPE, content_type)
|
||||||
.header(axum::http::header::AUTHORIZATION, bearer_auth().await)
|
.header(axum::http::header::AUTHORIZATION, super::bearer_auth().await)
|
||||||
.body(axum::body::Body::from_stream(body))
|
.body(axum::body::Body::from_stream(body))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
app.clone().oneshot(req).await
|
app.clone().oneshot(req).await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn queue_metadata_req(
|
pub async fn queue_metadata_req(
|
||||||
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> {
|
||||||
let payload = payload_data::queue_metadata_payload_data(&song_queue_id).await;
|
let payload = super::payload_data::queue_metadata_payload_data(&song_queue_id).await;
|
||||||
|
|
||||||
let req = axum::http::Request::builder()
|
let req = axum::http::Request::builder()
|
||||||
.method(axum::http::Method::POST)
|
.method(axum::http::Method::POST)
|
||||||
.uri(crate::callers::queue::endpoints::QUEUEMETADATA)
|
.uri(crate::callers::queue::endpoints::QUEUEMETADATA)
|
||||||
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
||||||
.header(axum::http::header::AUTHORIZATION, bearer_auth().await)
|
.header(axum::http::header::AUTHORIZATION, super::bearer_auth().await)
|
||||||
.body(axum::body::Body::from(payload.to_string()))
|
.body(axum::body::Body::from(payload.to_string()))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
app.clone().oneshot(req).await
|
app.clone().oneshot(req).await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn coverart_queue_song_queue_link_req(
|
pub async fn coverart_queue_song_queue_link_req(
|
||||||
app: &axum::Router,
|
app: &axum::Router,
|
||||||
coverart_id: &uuid::Uuid,
|
coverart_id: &uuid::Uuid,
|
||||||
song_queue_id: &uuid::Uuid,
|
song_queue_id: &uuid::Uuid,
|
||||||
@@ -610,14 +616,14 @@ mod tests {
|
|||||||
.method(axum::http::Method::PATCH)
|
.method(axum::http::Method::PATCH)
|
||||||
.uri(crate::callers::queue::endpoints::QUEUECOVERARTLINK)
|
.uri(crate::callers::queue::endpoints::QUEUECOVERARTLINK)
|
||||||
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
||||||
.header(axum::http::header::AUTHORIZATION, bearer_auth().await)
|
.header(axum::http::header::AUTHORIZATION, super::bearer_auth().await)
|
||||||
.body(axum::body::Body::from(payload.to_string()))
|
.body(axum::body::Body::from(payload.to_string()))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
app.clone().oneshot(req).await
|
app.clone().oneshot(req).await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn create_coverart_req(
|
pub async fn create_coverart_req(
|
||||||
app: &axum::Router,
|
app: &axum::Router,
|
||||||
song_id: &uuid::Uuid,
|
song_id: &uuid::Uuid,
|
||||||
coverart_id: &uuid::Uuid,
|
coverart_id: &uuid::Uuid,
|
||||||
@@ -630,31 +636,31 @@ mod tests {
|
|||||||
.method(axum::http::Method::POST)
|
.method(axum::http::Method::POST)
|
||||||
.uri(crate::callers::endpoints::CREATECOVERART)
|
.uri(crate::callers::endpoints::CREATECOVERART)
|
||||||
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
||||||
.header(axum::http::header::AUTHORIZATION, bearer_auth().await)
|
.header(axum::http::header::AUTHORIZATION, super::bearer_auth().await)
|
||||||
.body(axum::body::Body::from(payload.to_string()))
|
.body(axum::body::Body::from(payload.to_string()))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
app.clone().oneshot(req).await
|
app.clone().oneshot(req).await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn create_song_req(
|
pub async fn create_song_req(
|
||||||
app: &axum::Router,
|
app: &axum::Router,
|
||||||
song_queue_id: &uuid::Uuid,
|
song_queue_id: &uuid::Uuid,
|
||||||
user_id: &uuid::Uuid,
|
user_id: &uuid::Uuid,
|
||||||
) -> Result<axum::response::Response, std::convert::Infallible> {
|
) -> Result<axum::response::Response, std::convert::Infallible> {
|
||||||
let payload = payload_data::create_song(song_queue_id, user_id).await;
|
let payload = super::payload_data::create_song(song_queue_id, user_id).await;
|
||||||
|
|
||||||
let req = axum::http::Request::builder()
|
let req = axum::http::Request::builder()
|
||||||
.method(axum::http::Method::POST)
|
.method(axum::http::Method::POST)
|
||||||
.uri(crate::callers::endpoints::CREATESONG)
|
.uri(crate::callers::endpoints::CREATESONG)
|
||||||
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
||||||
.header(axum::http::header::AUTHORIZATION, bearer_auth().await)
|
.header(axum::http::header::AUTHORIZATION, super::bearer_auth().await)
|
||||||
.body(axum::body::Body::from(payload.to_string()))
|
.body(axum::body::Body::from(payload.to_string()))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
app.clone().oneshot(req).await
|
app.clone().oneshot(req).await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn update_song_queue_status_req(
|
pub async fn update_song_queue_status_req(
|
||||||
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> {
|
||||||
@@ -667,14 +673,14 @@ mod tests {
|
|||||||
.method(axum::http::Method::PATCH)
|
.method(axum::http::Method::PATCH)
|
||||||
.uri(crate::callers::queue::endpoints::QUEUESONG)
|
.uri(crate::callers::queue::endpoints::QUEUESONG)
|
||||||
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
||||||
.header(axum::http::header::AUTHORIZATION, bearer_auth().await)
|
.header(axum::http::header::AUTHORIZATION, super::bearer_auth().await)
|
||||||
.body(axum::body::Body::from(payload.to_string()))
|
.body(axum::body::Body::from(payload.to_string()))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
app.clone().oneshot(req).await
|
app.clone().oneshot(req).await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_queued_coverart(
|
pub async fn get_queued_coverart(
|
||||||
app: &axum::Router,
|
app: &axum::Router,
|
||||||
coverart_queue_id: &uuid::Uuid,
|
coverart_queue_id: &uuid::Uuid,
|
||||||
) -> Result<axum::response::Response, std::convert::Infallible> {
|
) -> Result<axum::response::Response, std::convert::Infallible> {
|
||||||
@@ -688,19 +694,21 @@ mod tests {
|
|||||||
.method(axum::http::Method::GET)
|
.method(axum::http::Method::GET)
|
||||||
.uri(uri)
|
.uri(uri)
|
||||||
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
||||||
.header(axum::http::header::AUTHORIZATION, bearer_auth().await)
|
.header(axum::http::header::AUTHORIZATION, super::bearer_auth().await)
|
||||||
.body(axum::body::Body::empty())
|
.body(axum::body::Body::empty())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
app.clone().oneshot(req).await
|
app.clone().oneshot(req).await
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
mod sequence_flow {
|
mod sequence_flow {
|
||||||
// Flow for queueing song
|
// Flow for queueing song
|
||||||
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 +721,7 @@ 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 +733,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 +743,7 @@ 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 +762,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 +772,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 +791,7 @@ 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 +814,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 +922,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 +958,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 +971,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 +1036,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 +1051,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 +1097,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 +1108,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");
|
||||||
@@ -1714,7 +1722,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 +1785,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,7 +1815,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");
|
||||||
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(&app, &song_id, &resp_queue_coverart_id)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
@@ -1976,7 +1984,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,
|
||||||
@@ -2070,6 +2078,7 @@ mod tests {
|
|||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use tower::ServiceExt;
|
use tower::ServiceExt;
|
||||||
|
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_get_songs() {
|
async fn test_get_songs() {
|
||||||
let tm_pool = super::db_mgr::get_pool().await.unwrap();
|
let tm_pool = super::db_mgr::get_pool().await.unwrap();
|
||||||
|
|||||||
Reference in New Issue
Block a user