tsk-206: Forgot some imports. Some cleanup
This commit is contained in:
+76
-26
@@ -469,7 +469,6 @@ mod tests {
|
|||||||
};
|
};
|
||||||
use tower::ServiceExt;
|
use tower::ServiceExt;
|
||||||
|
|
||||||
|
|
||||||
pub async fn song_queue_req(
|
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> {
|
||||||
@@ -484,7 +483,10 @@ 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, super::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
|
||||||
@@ -504,7 +506,10 @@ 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, super::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();
|
||||||
|
|
||||||
@@ -518,7 +523,10 @@ mod tests {
|
|||||||
.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, super::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
|
||||||
@@ -538,7 +546,10 @@ 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, super::bearer_auth().await)
|
.header(
|
||||||
|
axum::http::header::AUTHORIZATION,
|
||||||
|
super::bearer_auth().await,
|
||||||
|
)
|
||||||
.body(axum::body::Body::empty())
|
.body(axum::body::Body::empty())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@@ -556,8 +567,14 @@ mod tests {
|
|||||||
let req = axum::http::Request::builder()
|
let req = axum::http::Request::builder()
|
||||||
.method(axum::http::Method::GET)
|
.method(axum::http::Method::GET)
|
||||||
.uri(uri)
|
.uri(uri)
|
||||||
.header(axum::http::header::CONTENT_TYPE, "audio/flac")
|
.header(
|
||||||
.header(axum::http::header::AUTHORIZATION, super::bearer_auth().await)
|
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())
|
.body(axum::body::Body::empty())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@@ -568,7 +585,10 @@ mod tests {
|
|||||||
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();
|
||||||
let _ = form.add_file("jpg", "tests/I/Coverart-1.jpg");
|
let _ = form.add_file(
|
||||||
|
icarus_meta::detection::coverart::constants::JPEG_TYPE,
|
||||||
|
"tests/I/Coverart-1.jpg",
|
||||||
|
);
|
||||||
|
|
||||||
// Create request
|
// Create request
|
||||||
let content_type = form.content_type();
|
let content_type = form.content_type();
|
||||||
@@ -578,7 +598,10 @@ 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, super::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();
|
||||||
|
|
||||||
@@ -595,7 +618,10 @@ mod tests {
|
|||||||
.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, super::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();
|
||||||
|
|
||||||
@@ -616,7 +642,10 @@ 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, super::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();
|
||||||
|
|
||||||
@@ -636,7 +665,10 @@ 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, super::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
|
||||||
@@ -653,7 +685,10 @@ mod tests {
|
|||||||
.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, super::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();
|
||||||
|
|
||||||
@@ -673,7 +708,10 @@ 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, super::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();
|
||||||
|
|
||||||
@@ -694,7 +732,10 @@ 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, super::bearer_auth().await)
|
.header(
|
||||||
|
axum::http::header::AUTHORIZATION,
|
||||||
|
super::bearer_auth().await,
|
||||||
|
)
|
||||||
.body(axum::body::Body::empty())
|
.body(axum::body::Body::empty())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@@ -702,7 +743,6 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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(
|
||||||
@@ -721,7 +761,8 @@ mod tests {
|
|||||||
|
|
||||||
let user_id = super::TEST_USER_ID;
|
let user_id = super::TEST_USER_ID;
|
||||||
|
|
||||||
match super::request::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,
|
||||||
@@ -743,7 +784,8 @@ mod tests {
|
|||||||
|
|
||||||
let id = resp.data[0];
|
let id = resp.data[0];
|
||||||
|
|
||||||
match super::request::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),
|
||||||
}
|
}
|
||||||
@@ -791,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::request::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),
|
||||||
}
|
}
|
||||||
@@ -1455,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,
|
||||||
@@ -1466,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,
|
||||||
@@ -1476,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::<
|
||||||
@@ -1815,8 +1862,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 request::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::<
|
||||||
@@ -2078,7 +2129,6 @@ 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