Added more types
All checks were successful
Rust Build / Check (pull_request) Successful in 31s
Rust Build / Test Suite (pull_request) Successful in 37s
Rust Build / Rustfmt (pull_request) Successful in 29s
Rust Build / Clippy (pull_request) Successful in 30s
Rust Build / build (pull_request) Successful in 39s
All checks were successful
Rust Build / Check (pull_request) Successful in 31s
Rust Build / Test Suite (pull_request) Successful in 37s
Rust Build / Rustfmt (pull_request) Successful in 29s
Rust Build / Clippy (pull_request) Successful in 30s
Rust Build / build (pull_request) Successful in 39s
AlbumArtist and Disc
This commit is contained in:
62
src/meta.rs
62
src/meta.rs
@@ -7,9 +7,11 @@ fn get_type(t: types::Type) -> Result<String, std::io::Error> {
|
|||||||
types::Type::Title => Ok("TITLE".to_owned()),
|
types::Type::Title => Ok("TITLE".to_owned()),
|
||||||
types::Type::Artist => Ok("ARTIST".to_owned()),
|
types::Type::Artist => Ok("ARTIST".to_owned()),
|
||||||
types::Type::Album => Ok("ALBUM".to_owned()),
|
types::Type::Album => Ok("ALBUM".to_owned()),
|
||||||
|
types::Type::AlbumArtist => Ok("ALBUMARTIST".to_owned()),
|
||||||
types::Type::Genre => Ok("GENRE".to_owned()),
|
types::Type::Genre => Ok("GENRE".to_owned()),
|
||||||
types::Type::Date => Ok("DATE".to_owned()),
|
types::Type::Date => Ok("DATE".to_owned()),
|
||||||
types::Type::Track => Ok("TRACKNUMBER".to_owned()),
|
types::Type::Track => Ok("TRACKNUMBER".to_owned()),
|
||||||
|
types::Type::Disc => Ok("DISCNUMBER".to_owned()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,6 +107,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_get_artist() {
|
fn test_get_artist() {
|
||||||
let filename = String::from("track01.flac");
|
let filename = String::from("track01.flac");
|
||||||
@@ -129,6 +132,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_get_album() {
|
fn test_get_album() {
|
||||||
let filename = String::from("track01.flac");
|
let filename = String::from("track01.flac");
|
||||||
@@ -153,6 +157,32 @@ mod tests {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_get_album_artist() {
|
||||||
|
let filename = String::from("track01.flac");
|
||||||
|
let dir = util::test_file_directory();
|
||||||
|
|
||||||
|
match file_exists(&dir, &filename) {
|
||||||
|
Ok(_) => {
|
||||||
|
let filepath = get_full_path(&dir, &filename).unwrap();
|
||||||
|
|
||||||
|
match get_meta(types::Type::AlbumArtist, &filepath) {
|
||||||
|
Ok(album_artist) => {
|
||||||
|
let found = album_artist == "KD";
|
||||||
|
assert!(found, "Meta information was not found {:?}", album_artist);
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
assert!(false, "Error: {:?}", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
assert!(false, "Error: File does not exist {:?}", err.to_string());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_get_genre() {
|
fn test_get_genre() {
|
||||||
let filename = String::from("track01.flac");
|
let filename = String::from("track01.flac");
|
||||||
@@ -187,9 +217,9 @@ mod tests {
|
|||||||
let filepath = get_full_path(&dir, &filename).unwrap();
|
let filepath = get_full_path(&dir, &filename).unwrap();
|
||||||
|
|
||||||
match get_meta(types::Type::Date, &filepath) {
|
match get_meta(types::Type::Date, &filepath) {
|
||||||
Ok(year) => {
|
Ok(date) => {
|
||||||
let found = year == "2025-04-11";
|
let found = date == "2025-04-11";
|
||||||
assert!(found, "Meta information was not found {:?}", year);
|
assert!(found, "Meta information was not found {:?}", date);
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
assert!(false, "Error: {:?}", err);
|
assert!(false, "Error: {:?}", err);
|
||||||
@@ -201,6 +231,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_get_track() {
|
fn test_get_track() {
|
||||||
let filename = String::from("track01.flac");
|
let filename = String::from("track01.flac");
|
||||||
@@ -225,4 +256,29 @@ mod tests {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_get_disc() {
|
||||||
|
let filename = String::from("track01.flac");
|
||||||
|
let dir = util::test_file_directory();
|
||||||
|
|
||||||
|
match file_exists(&dir, &filename) {
|
||||||
|
Ok(_) => {
|
||||||
|
let filepath = get_full_path(&dir, &filename).unwrap();
|
||||||
|
|
||||||
|
match get_meta(types::Type::Disc, &filepath) {
|
||||||
|
Ok(disc) => {
|
||||||
|
let found = disc == "1";
|
||||||
|
assert!(found, "Meta information was not found {:?}", disc);
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
assert!(false, "Error: {:?}", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
assert!(false, "Error: File does not exist {:?}", err.to_string());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,9 @@ pub enum Type {
|
|||||||
Title,
|
Title,
|
||||||
Artist,
|
Artist,
|
||||||
Album,
|
Album,
|
||||||
|
AlbumArtist,
|
||||||
Genre,
|
Genre,
|
||||||
Date,
|
Date,
|
||||||
Track,
|
Track,
|
||||||
|
Disc,
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user