Code formatting
This commit is contained in:
@@ -19,7 +19,6 @@ pub mod endpoints {
|
|||||||
pub const CREATECOVERART: &str = "/api/v2/coverart";
|
pub const CREATECOVERART: &str = "/api/v2/coverart";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub mod response {
|
pub mod response {
|
||||||
pub const SUCCESSFUL: &str = "SUCCESSFUL";
|
pub const SUCCESSFUL: &str = "SUCCESSFUL";
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-2
@@ -659,12 +659,19 @@ pub mod endpoint {
|
|||||||
(StatusCode::OK, Json(response))
|
(StatusCode::OK, Json(response))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn link_user_id(axum::Extension(pool): axum::Extension<sqlx::PgPool>, axum::Json(payload): axum::Json<super::request::link_user_id::Request>) -> (axum::http::StatusCode, axum::Json<super::response::link_user_id::Response>) {
|
pub async fn link_user_id(
|
||||||
|
axum::Extension(pool): axum::Extension<sqlx::PgPool>,
|
||||||
|
axum::Json(payload): axum::Json<super::request::link_user_id::Request>,
|
||||||
|
) -> (
|
||||||
|
axum::http::StatusCode,
|
||||||
|
axum::Json<super::response::link_user_id::Response>,
|
||||||
|
) {
|
||||||
let mut response = super::response::link_user_id::Response::default();
|
let mut response = super::response::link_user_id::Response::default();
|
||||||
|
|
||||||
match super::song_queue::get_song_queue(&pool, &payload.song_queue_id).await {
|
match super::song_queue::get_song_queue(&pool, &payload.song_queue_id).await {
|
||||||
Ok(song_queue) => {
|
Ok(song_queue) => {
|
||||||
match super::song_queue::link_user_id(&pool, &song_queue.id, &payload.user_id).await {
|
match super::song_queue::link_user_id(&pool, &song_queue.id, &payload.user_id).await
|
||||||
|
{
|
||||||
Ok(user_id) => {
|
Ok(user_id) => {
|
||||||
response.message = String::from(crate::callers::response::SUCCESSFUL);
|
response.message = String::from(crate::callers::response::SUCCESSFUL);
|
||||||
response.data.push(user_id);
|
response.data.push(user_id);
|
||||||
|
|||||||
+8
-31
@@ -61,7 +61,7 @@ pub mod init {
|
|||||||
)
|
)
|
||||||
.route(
|
.route(
|
||||||
crate::callers::endpoints::QUEUESONGLINKUSERID,
|
crate::callers::endpoints::QUEUESONGLINKUSERID,
|
||||||
patch(crate::callers::song::endpoint::link_user_id)
|
patch(crate::callers::song::endpoint::link_user_id),
|
||||||
)
|
)
|
||||||
.route(
|
.route(
|
||||||
crate::callers::endpoints::QUEUESONGDATA,
|
crate::callers::endpoints::QUEUESONGDATA,
|
||||||
@@ -663,7 +663,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_song_fetch_queue_item() {
|
async fn test_song_fetch_queue_item() {
|
||||||
let tm_pool = db_mgr::get_pool().await.unwrap();
|
let tm_pool = db_mgr::get_pool().await.unwrap();
|
||||||
@@ -705,10 +704,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 changed_status = &resp.data[0];
|
let changed_status = &resp.data[0];
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(*old, changed_status.old_status, "Old status does not match");
|
||||||
*old, changed_status.old_status,
|
|
||||||
"Old status does not match"
|
|
||||||
);
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
target_status, changed_status.new_status,
|
target_status, changed_status.new_status,
|
||||||
"New status does not match"
|
"New status does not match"
|
||||||
@@ -772,11 +768,7 @@ mod tests {
|
|||||||
match fetch_queue_data_req(&app, &id).await {
|
match fetch_queue_data_req(&app, &id).await {
|
||||||
Ok(response) => match resp_to_bytes(response).await {
|
Ok(response) => match resp_to_bytes(response).await {
|
||||||
Ok(bytes) => {
|
Ok(bytes) => {
|
||||||
assert_eq!(
|
assert_eq!(false, bytes.is_empty(), "Queued data should not be empty");
|
||||||
false,
|
|
||||||
bytes.is_empty(),
|
|
||||||
"Queued data should not be empty"
|
|
||||||
);
|
|
||||||
|
|
||||||
let temp_file =
|
let temp_file =
|
||||||
tempfile::tempdir().expect("Could not create test directory");
|
tempfile::tempdir().expect("Could not create test directory");
|
||||||
@@ -793,8 +785,7 @@ mod tests {
|
|||||||
let content_type = form.content_type();
|
let content_type = form.content_type();
|
||||||
let body = MultipartBody::from(form);
|
let body = MultipartBody::from(form);
|
||||||
|
|
||||||
let raw_uri =
|
let raw_uri = String::from(crate::callers::endpoints::QUEUESONGUPDATE);
|
||||||
String::from(crate::callers::endpoints::QUEUESONGUPDATE);
|
|
||||||
let end_index = raw_uri.len() - 5;
|
let end_index = raw_uri.len() - 5;
|
||||||
|
|
||||||
let uri = format!(
|
let uri = format!(
|
||||||
@@ -820,11 +811,7 @@ mod tests {
|
|||||||
crate::callers::song::response::update_song_queue::Response,
|
crate::callers::song::response::update_song_queue::Response,
|
||||||
>(response)
|
>(response)
|
||||||
.await;
|
.await;
|
||||||
assert_eq!(
|
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||||
false,
|
|
||||||
resp.data.is_empty(),
|
|
||||||
"Should not be empty"
|
|
||||||
);
|
|
||||||
|
|
||||||
let updated_song_queued_id = resp.data[0];
|
let updated_song_queued_id = resp.data[0];
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@@ -886,11 +873,7 @@ mod tests {
|
|||||||
match fetch_queue_data_req(&app, &id).await {
|
match fetch_queue_data_req(&app, &id).await {
|
||||||
Ok(response) => match resp_to_bytes(response).await {
|
Ok(response) => match resp_to_bytes(response).await {
|
||||||
Ok(bytes) => {
|
Ok(bytes) => {
|
||||||
assert_eq!(
|
assert_eq!(false, bytes.is_empty(), "Queued data should not be empty");
|
||||||
false,
|
|
||||||
bytes.is_empty(),
|
|
||||||
"Queued data should not be empty"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
assert!(false, "Error: {:?}", err);
|
assert!(false, "Error: {:?}", err);
|
||||||
@@ -950,14 +933,8 @@ 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 changed_status = &resp.data[0];
|
let changed_status = &resp.data[0];
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(*old, changed_status.old_status, "Old status does not match");
|
||||||
*old, changed_status.old_status,
|
assert_eq!(done, changed_status.new_status, "New status does not match");
|
||||||
"Old status does not match"
|
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
done, changed_status.new_status,
|
|
||||||
"New status does not match"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
assert!(false, "Error: {:?}", err);
|
assert!(false, "Error: {:?}", err);
|
||||||
|
|||||||
Reference in New Issue
Block a user