Get songs endpoint #162

Merged
kdeng00 merged 27 commits from get_songs into v0.2 2025-07-25 18:20:28 -04:00
Showing only changes of commit 2b3afa4ff5 - Show all commits
+20 -11
View File
@@ -117,7 +117,7 @@ pub mod init {
) )
.route( .route(
crate::callers::endpoints::GETSONGS, crate::callers::endpoints::GETSONGS,
get(crate::callers::song::endpoint::get_songs) get(crate::callers::song::endpoint::get_songs),
) )
} }
@@ -1834,6 +1834,8 @@ mod tests {
let pool = super::db_mgr::connect_to_db(&db_name).await.unwrap(); let pool = super::db_mgr::connect_to_db(&db_name).await.unwrap();
super::db_mgr::migrations(&pool).await; super::db_mgr::migrations(&pool).await;
let app = super::init::app(pool).await;
let mut id = uuid::Uuid::nil(); let mut id = uuid::Uuid::nil();
match uuid::Uuid::parse_str("44cf7940-34ff-489f-9124-d0ec90a55af9") { match uuid::Uuid::parse_str("44cf7940-34ff-489f-9124-d0ec90a55af9") {
Ok(val) => { Ok(val) => {
@@ -1843,19 +1845,26 @@ mod tests {
assert!(false, "Error: {err:?}"); assert!(false, "Error: {err:?}");
} }
}; };
let uri = format!("{}?id={id}", crate::callers::endpoints::GETSONGS); let uri = format!("{}?id={id}", crate::callers::endpoints::GETSONGS);
let app = super::init::app(pool).await; match app
match app.clone().oneshot( .clone()
axum::http::Request::builder() .oneshot(
.method(axum::http::Method::GET) axum::http::Request::builder()
.uri(uri) .method(axum::http::Method::GET)
.header(axum::http::header::CONTENT_TYPE, "application/json") .uri(uri)
.body(axum::body::Body::empty()) .header(axum::http::header::CONTENT_TYPE, "application/json")
.unwrap() .body(axum::body::Body::empty())
).await { .unwrap(),
)
.await
{
Ok(response) => { Ok(response) => {
let resp = super::get_resp_data::<crate::callers::song::response::get_songs::Response>(response).await; let resp = super::get_resp_data::<
crate::callers::song::response::get_songs::Response,
>(response)
.await;
assert_eq!(false, resp.data.is_empty(), "Should not be empty"); assert_eq!(false, resp.data.is_empty(), "Should not be empty");
let song = resp.data[0].clone(); let song = resp.data[0].clone();