From aea8b14e14ea7e94b552565648edb89ee869279e Mon Sep 17 00:00:00 2001 From: phoenix Date: Fri, 14 Aug 2026 11:55:19 -0400 Subject: [PATCH] Saving changes --- src/main.rs | 97 ++++++++++++++++++- .../20250725214735_song_queue_processed.sql | 13 ++- 2 files changed, 105 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index e07b4f6..2cbe9fe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -500,10 +500,103 @@ mod tests { } mod sequence_flow { + use std::io::Read; + + pub const TEST_SONG_01_FILE_KEY: &str = "processed/song/track01.flac"; + pub const TEST_SONG_02_FILE_KEY: &str = "processed/song/track02.flac"; + + pub struct SongBucket { + pub file_key: String, + pub path: String, + } + + pub async fn upload_test_songs_to_bucket() { + let lab_config = soaricarus_api::util::maze::get_config(); + + let songs = vec![ + SongBucket { + file_key: TEST_SONG_01_FILE_KEY.to_string(), + path: "tests/I/track01.flac".to_string(), + }, + SongBucket { + file_key: TEST_SONG_02_FILE_KEY.to_string(), + path: "tests/I/track02.flac".to_string(), + }, + ]; + + let lr = labyrinth::Labyrinth { config: lab_config }; + + for song in &songs { + let p = std::path::Path::new(&song.path); + // match std::fs::File::open(p) { + match tokio::fs::File::open(p).await { + Ok(mut _file) => { + let data = labyrinth::Data { + // raw_data: buffer, + filepath: song.path.clone(), + ..Default::default() + }; + + match lr.upload(&song.file_key, &data).await { + Ok(_) => {} + Err(err) => { + assert!(false, "Error: {err:?}"); + } + } + + /* + let mut buffer: Vec = Vec::new(); + match file.read_to_end(&mut buffer) { + Ok(_) => { + if buffer.is_empty() { + + } else { + } + } + Err(err) => { + assert!(false, "Error: {err:?}"); + } + } + */ + } + Err(err) => { + assert!(false, "Error: {err:?}"); + } + }; + } + } + + pub async fn delete_test_songs_to_bucket() { + let lab_config = soaricarus_api::util::maze::get_config(); + + let songs = vec![ + SongBucket { + file_key: TEST_SONG_01_FILE_KEY.to_string(), + path: "tests/I/track01.flac".to_string(), + }, + SongBucket { + file_key: TEST_SONG_02_FILE_KEY.to_string(), + path: "tests/I/track02.flac".to_string(), + }, + ]; + + let lr = labyrinth::Labyrinth { config: lab_config }; + + for song in &songs { + match lr.delete(&song.file_key).await { + Ok(_) => {} + Err(err) => { + assert!(false, "Error: {err:?}"); + } + } + } + } + // Flow for queueing song pub async fn queue_song_flow( app: &axum::Router, ) -> Result<(axum::response::Response, uuid::Uuid), axum::http::Error> { + upload_test_songs_to_bucket().await; match super::request::song_queue_req(&app).await { Ok(response) => { let resp = super::util::get_resp_data::< @@ -622,6 +715,7 @@ mod tests { soaricarus_api::callers::song::response::create_metadata::Response, >(response) .await; + assert_eq!(false, resp.data.is_empty(), "Node"); assert_eq!( false, resp.data.is_empty(), @@ -637,7 +731,7 @@ mod tests { song ); - eprintln!("Song: {:?}", song); + // eprintln!("Song: {:?}", song); match queue_coverart_flow(&app, &song_queue_id).await { Ok(response) => Ok((response, song_queue_id)), @@ -1111,6 +1205,7 @@ mod tests { match sequence_flow::queue_song_and_coverart_flow(&app).await { Ok((resp_one, song_queue_id)) => { + assert!(false, "Got here 2"); let resp = util::get_resp_data::< soaricarus_api::callers::queue::coverart::response::fetch_coverart_no_data::Response, >(resp_one) diff --git a/test_migrations/20250725214735_song_queue_processed.sql b/test_migrations/20250725214735_song_queue_processed.sql index 96f179b..6453b11 100644 --- a/test_migrations/20250725214735_song_queue_processed.sql +++ b/test_migrations/20250725214735_song_queue_processed.sql @@ -1,6 +1,11 @@ -- Add migration script here -INSERT INTO "song" (id, title, artist, album_artist, album, genre, year, track, disc, track_count, disc_count, duration, audio_type, date_created, filename, directory, user_id) VALUES('44cf7940-34ff-489f-9124-d0ec90a55af9', 'Hypocrite Like The Rest', 'Kuoth', 'Kuoth', 'I', 'Alternative Hip-Hop', 2020, 1, 1, 9, 1, 139, 'flac', '2020-01-01 13:00:00-05', 'track01.flac', 'tests/I', '47491f9b-725a-4ba4-b9a5-711e1be46670'); -INSERT INTO "coverart" (id, title, directory, filename, file_type, song_id) VALUES('996122cd-5ae9-4013-9934-60768d3006ed', 'I', 'tests/I', 'Coverart-1.jpg', 'jpeg', '44cf7940-34ff-489f-9124-d0ec90a55af9'); +INSERT INTO "song" (id, title, artist, album_artist, album, genre, year, track, disc, track_count, disc_count, duration, audio_type, date_created, filename, directory, file_key, user_id) +VALUES('44cf7940-34ff-489f-9124-d0ec90a55af9', 'Hypocrite Like The Rest', 'Kuoth', 'Kuoth', 'I', 'Alternative Hip-Hop', 2020, 1, 1, 9, 1, 139, 'flac', '2020-01-01 13:00:00-05', 'track01.flac', 'tests/I', 'processed/song/track01.flac', '47491f9b-725a-4ba4-b9a5-711e1be46670'); -INSERT INTO "song" (id, title, artist, album_artist, album, genre, year, track, disc, track_count, disc_count, duration, audio_type, date_created, filename, directory, user_id) VALUES('94cf7940-34ff-489f-9124-d0ec90a55af4', 'It''s Too Late', 'Kuoth', 'Kuoth', 'I', 'Alternative Hip-Hop', 2020, 2, 1, 9, 1, 116, 'flac', '2020-01-01 13:01:00-05', 'track02.flac', 'tests/I', '47491f9b-725a-4ba4-b9a5-711e1be46670'); -INSERT INTO "coverart" (id, title, directory, filename, file_type, song_id) VALUES('d96122cd-5ae9-4013-9934-60768d3006e9', 'I', 'tests/I', 'Coverart-2.jpg', 'jpeg', '94cf7940-34ff-489f-9124-d0ec90a55af4'); +INSERT INTO "coverart" (id, title, directory, filename, file_type, song_id) +VALUES('996122cd-5ae9-4013-9934-60768d3006ed', 'I', 'tests/I', 'Coverart-1.jpg', 'jpeg', '44cf7940-34ff-489f-9124-d0ec90a55af9'); + +INSERT INTO "song" (id, title, artist, album_artist, album, genre, year, track, disc, track_count, disc_count, duration, audio_type, date_created, filename, directory, file_key, user_id) +VALUES('94cf7940-34ff-489f-9124-d0ec90a55af4', 'It''s Too Late', 'Kuoth', 'Kuoth', 'I', 'Alternative Hip-Hop', 2020, 2, 1, 9, 1, 116, 'flac', '2020-01-01 13:01:00-05', 'track02.flac', 'tests/I', 'processed/song/track02.flac', '47491f9b-725a-4ba4-b9a5-711e1be46670'); +INSERT INTO "coverart" (id, title, directory, filename, file_type, song_id) +VALUES('d96122cd-5ae9-4013-9934-60768d3006e9', 'I', 'tests/I', 'Coverart-2.jpg', 'jpeg', '94cf7940-34ff-489f-9124-d0ec90a55af4');