S3 song download #260
+96
-1
@@ -500,10 +500,103 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod sequence_flow {
|
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<u8> = 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
|
// Flow for queueing song
|
||||||
pub async fn queue_song_flow(
|
pub async fn queue_song_flow(
|
||||||
app: &axum::Router,
|
app: &axum::Router,
|
||||||
) -> Result<(axum::response::Response, uuid::Uuid), axum::http::Error> {
|
) -> Result<(axum::response::Response, uuid::Uuid), axum::http::Error> {
|
||||||
|
upload_test_songs_to_bucket().await;
|
||||||
match super::request::song_queue_req(&app).await {
|
match super::request::song_queue_req(&app).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
let resp = super::util::get_resp_data::<
|
let resp = super::util::get_resp_data::<
|
||||||
@@ -622,6 +715,7 @@ mod tests {
|
|||||||
soaricarus_api::callers::song::response::create_metadata::Response,
|
soaricarus_api::callers::song::response::create_metadata::Response,
|
||||||
>(response)
|
>(response)
|
||||||
.await;
|
.await;
|
||||||
|
assert_eq!(false, resp.data.is_empty(), "Node");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
false,
|
false,
|
||||||
resp.data.is_empty(),
|
resp.data.is_empty(),
|
||||||
@@ -637,7 +731,7 @@ mod tests {
|
|||||||
song
|
song
|
||||||
);
|
);
|
||||||
|
|
||||||
eprintln!("Song: {:?}", song);
|
// eprintln!("Song: {:?}", song);
|
||||||
|
|
||||||
match queue_coverart_flow(&app, &song_queue_id).await {
|
match queue_coverart_flow(&app, &song_queue_id).await {
|
||||||
Ok(response) => Ok((response, song_queue_id)),
|
Ok(response) => Ok((response, song_queue_id)),
|
||||||
@@ -1111,6 +1205,7 @@ mod tests {
|
|||||||
|
|
||||||
match sequence_flow::queue_song_and_coverart_flow(&app).await {
|
match sequence_flow::queue_song_and_coverart_flow(&app).await {
|
||||||
Ok((resp_one, song_queue_id)) => {
|
Ok((resp_one, song_queue_id)) => {
|
||||||
|
assert!(false, "Got here 2");
|
||||||
let resp = util::get_resp_data::<
|
let resp = util::get_resp_data::<
|
||||||
soaricarus_api::callers::queue::coverart::response::fetch_coverart_no_data::Response,
|
soaricarus_api::callers::queue::coverart::response::fetch_coverart_no_data::Response,
|
||||||
>(resp_one)
|
>(resp_one)
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
-- Add migration script here
|
-- 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 "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)
|
||||||
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');
|
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)
|
||||||
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');
|
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');
|
||||||
|
|||||||
Reference in New Issue
Block a user