Added more fields #18
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::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());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,9 @@ pub enum Type {
|
||||
Title,
|
||||
Artist,
|
||||
Album,
|
||||
AlbumArtist,
|
||||
Genre,
|
||||
Date,
|
||||
Track,
|
||||
Disc,
|
||||
}
|
||||
|
Reference in New Issue
Block a user