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

AlbumArtist and Disc
This commit is contained in:
2025-04-14 20:31:43 -04:00
parent b7df0a1994
commit 595888e980
2 changed files with 61 additions and 3 deletions

View File

@@ -7,9 +7,11 @@ fn get_type(t: types::Type) -> Result<String, std::io::Error> {
types::Type::Title => Ok("TITLE".to_owned()),
types::Type::Artist => Ok("ARTIST".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::Date => Ok("DATE".to_owned()),
types::Type::Track => Ok("TRACKNUMBER".to_owned()),
types::Type::Disc => Ok("DISCNUMBER".to_owned()),
}
}
@@ -105,6 +107,7 @@ mod tests {
}
};
}
#[test]
fn test_get_artist() {
let filename = String::from("track01.flac");
@@ -129,6 +132,7 @@ mod tests {
}
};
}
#[test]
fn test_get_album() {
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]
fn test_get_genre() {
let filename = String::from("track01.flac");
@@ -187,9 +217,9 @@ mod tests {
let filepath = get_full_path(&dir, &filename).unwrap();
match get_meta(types::Type::Date, &filepath) {
Ok(year) => {
let found = year == "2025-04-11";
assert!(found, "Meta information was not found {:?}", year);
Ok(date) => {
let found = date == "2025-04-11";
assert!(found, "Meta information was not found {:?}", date);
}
Err(err) => {
assert!(false, "Error: {:?}", err);
@@ -201,6 +231,7 @@ mod tests {
}
};
}
#[test]
fn test_get_track() {
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());
}
};
}
}

View File

@@ -2,7 +2,9 @@ pub enum Type {
Title,
Artist,
Album,
AlbumArtist,
Genre,
Date,
Track,
Disc,
}