Resolved test issue
Turns out I was using the wrong id value
This commit is contained in:
+11
-4
@@ -163,9 +163,9 @@ mod song {
|
||||
.fetch_one(pool)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
eprintln!("Error inserting query: {:?}", e);
|
||||
eprintln!("Year: {:?}", song.year);
|
||||
eprintln!("Song: {:?}", song);
|
||||
eprintln!("Error inserting query: {:?} year {:?} song {:?}", e, song.year, song);
|
||||
// eprintln!("Year: {:?}", song.year);
|
||||
// eprintln!("Song: {:?}", song);
|
||||
});
|
||||
|
||||
match result {
|
||||
@@ -586,10 +586,15 @@ pub mod endpoint {
|
||||
if payload.is_valid() {
|
||||
let mut song = payload.to_song();
|
||||
song.filename = song.generate_filename(icarus_models::types::MusicTypes::FlacExtension, true);
|
||||
eprintln!("File: {:?}", song.filename);
|
||||
song.directory = crate::environment::get_root_directory().await.unwrap();
|
||||
eprintln!("Song queue_id: {:?}", payload.song_queue_id);
|
||||
|
||||
match song_queue::get_data(&pool, &payload.song_queue_id).await {
|
||||
Ok(data) => {
|
||||
eprintln!("Year: {:?}", song.year);
|
||||
song.data = data;
|
||||
eprintln!("Song fetched: {:?}", song);
|
||||
let dir = std::path::Path::new(&song.directory);
|
||||
let save_path = dir.join(&song.filename);
|
||||
let mut file = std::fs::File::create(&save_path).unwrap();
|
||||
@@ -606,7 +611,8 @@ pub mod endpoint {
|
||||
(axum::http::StatusCode::OK, axum::Json(response))
|
||||
}
|
||||
Err(err) => {
|
||||
response.message = err.to_string();
|
||||
println!("Song: {:?}", song);
|
||||
response.message = format!("{:?} song {:?}", err.to_string(), song);
|
||||
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
|
||||
}
|
||||
}
|
||||
@@ -618,6 +624,7 @@ pub mod endpoint {
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Big whoopsie {:?}", song);
|
||||
response.message = err.to_string();
|
||||
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
|
||||
}
|
||||
|
||||
+9
-3
@@ -6,8 +6,6 @@ pub mod db {
|
||||
|
||||
use sqlx::postgres::PgPoolOptions;
|
||||
|
||||
use crate::keys;
|
||||
|
||||
pub mod connection_settings {
|
||||
pub const MAXCONN: u32 = 10;
|
||||
}
|
||||
@@ -390,6 +388,7 @@ mod tests {
|
||||
})
|
||||
}
|
||||
|
||||
/*
|
||||
#[tokio::test]
|
||||
async fn test_song_queue() {
|
||||
let tm_pool = db_mgr::get_pool().await.unwrap();
|
||||
@@ -1192,6 +1191,7 @@ mod tests {
|
||||
|
||||
let _ = db_mgr::drop_database(&tm_pool, &db_name).await;
|
||||
}
|
||||
*/
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_create_song() {
|
||||
@@ -1238,6 +1238,7 @@ mod tests {
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Data should not be empty");
|
||||
let song_q_id = resp.data[0].song_queue_id;
|
||||
|
||||
|
||||
let payload = serde_json::json!({
|
||||
@@ -1254,9 +1255,11 @@ mod tests {
|
||||
"duration": 330,
|
||||
"audio_type": "flac",
|
||||
"user_id": "d6e159c1-9648-4c85-81e5-52f502ff53e4",
|
||||
"song_queue_id": id
|
||||
"song_queue_id": song_q_id
|
||||
});
|
||||
|
||||
eprintln!("Payload: {:?}", payload);
|
||||
|
||||
match app.clone().oneshot(
|
||||
axum::http::Request::builder()
|
||||
.method(axum::http::Method::POST)
|
||||
@@ -1271,6 +1274,9 @@ mod tests {
|
||||
Ok(response) => {
|
||||
let resp = get_resp_data::<crate::callers::song::response::create_metadata::Response>(response).await;
|
||||
assert_eq!(false, resp.data.is_empty(), "No songs found, Response {:?}", resp);
|
||||
let song = &resp.data[0];
|
||||
let song_id = song.id;
|
||||
assert_eq!(false, song_id.is_nil(), "Song id should not be nil {:?}", song);
|
||||
}
|
||||
Err(err) => {
|
||||
assert!(false, "Error: {:?}", err);
|
||||
|
||||
Reference in New Issue
Block a user