Create more tests for the `search_for` function

This commit is contained in:
Anas Elgarhy 2023-02-08 22:25:41 +02:00
parent eb3715f4cb
commit 97e6a346a8
No known key found for this signature in database
GPG Key ID: 0501802A1D496528
3 changed files with 29 additions and 4 deletions

View File

@ -99,7 +99,7 @@ mod tests {
#[test]
fn test_search_for_cover_with_the_cover_key_world() {
let cover_path = search_for(
"tests/samples/Owl City/Cinematic",
"tests/samples/Owl City/Cinematic/cover",
1,
r"cover|.\.jpg|.\.png",
);
@ -107,18 +107,43 @@ mod tests {
assert_matches!(cover_path, Ok(Some(_)));
assert_eq!(
cover_path.unwrap().unwrap(),
"tests/samples/Owl City/Cinematic/cover.jpg"
"tests/samples/Owl City/Cinematic/cover/cover.jpg"
);
}
#[test]
fn test_search_for_cover_without_the_cover_key_world() {
let cover_path = search_for("tests/samples/Owl City/Cinematic", 1, r".\.jpg|.\.png");
let cover_path = search_for(
"tests/samples/Owl City/Cinematic/cover", 1, r".\.jpg|.\.png");
assert_matches!(cover_path, Ok(Some(_)));
assert_eq!(
cover_path.unwrap().unwrap(),
"tests/samples/Owl City/Cinematic/cover.jpg"
"tests/samples/Owl City/Cinematic/cover/cover.jpg"
);
}
#[test]
fn test_search_for_cover_without_the_cover_key_world_and_jpg() {
let cover_path = search_for(
"tests/samples/Owl City/Cinematic/cover", 1, r".\.png");
assert_matches!(cover_path, Ok(Some(_)));
assert_eq!(
cover_path.unwrap().unwrap(),
"tests/samples/Owl City/Cinematic/cover/cover.png"
);
}
#[test]
fn test_search_for_lrc_file_started_from_the_cover_directory() {
let lrc_path = search_for(
"tests/samples/Owl City/Cinematic/cover", 1, r".\.lrc");
assert_matches!(lrc_path, Ok(Some(_)));
assert_eq!(
lrc_path.unwrap().unwrap(),
"tests/samples/Owl City/Cinematic/08 - Always.lrc"
);
}
}

View File

Before

Width:  |  Height:  |  Size: 966 KiB

After

Width:  |  Height:  |  Size: 966 KiB

View File

Before

Width:  |  Height:  |  Size: 2.3 MiB

After

Width:  |  Height:  |  Size: 2.3 MiB