Simplify test code
All checks were successful
Rust Build / Check (pull_request) Successful in 31s
Rust Build / Test Suite (pull_request) Successful in 39s
Rust Build / Rustfmt (pull_request) Successful in 28s
Rust Build / Clippy (pull_request) Successful in 30s
Rust Build / build (pull_request) Successful in 39s

This commit is contained in:
2025-04-14 20:46:11 -04:00
parent 595888e980
commit 4cc4421a13

View File

@@ -78,15 +78,28 @@ mod tests {
Ok(dir_path.join(filename))
}
pub fn test_file_directory() -> String {
String::from("tests/sample_tracks3")
pub const TESTFILEDIRECTORY: &str = "tests/sample_tracks3";
pub fn get_filename(track: i32) -> String {
let mut filename = String::from("track");
if track < 10 {
filename += "0";
filename += &track.to_string();
} else {
filename += &track.to_string();
}
filename += ".flac";
filename
}
}
#[test]
fn test_get_title() {
let filename = String::from("track01.flac");
let dir = util::test_file_directory();
let filename = util::get_filename(1);
let dir = String::from(util::TESTFILEDIRECTORY);
match file_exists(&dir, &filename) {
Ok(_) => {
@@ -110,8 +123,8 @@ mod tests {
#[test]
fn test_get_artist() {
let filename = String::from("track01.flac");
let dir = util::test_file_directory();
let filename = util::get_filename(1);
let dir = String::from(util::TESTFILEDIRECTORY);
match file_exists(&dir, &filename) {
Ok(_) => {
@@ -135,8 +148,8 @@ mod tests {
#[test]
fn test_get_album() {
let filename = String::from("track01.flac");
let dir = util::test_file_directory();
let filename = util::get_filename(1);
let dir = String::from(util::TESTFILEDIRECTORY);
match file_exists(&dir, &filename) {
Ok(_) => {
@@ -160,8 +173,8 @@ mod tests {
#[test]
fn test_get_album_artist() {
let filename = String::from("track01.flac");
let dir = util::test_file_directory();
let filename = util::get_filename(1);
let dir = String::from(util::TESTFILEDIRECTORY);
match file_exists(&dir, &filename) {
Ok(_) => {
@@ -185,8 +198,8 @@ mod tests {
#[test]
fn test_get_genre() {
let filename = String::from("track01.flac");
let dir = util::test_file_directory();
let filename = util::get_filename(1);
let dir = String::from(util::TESTFILEDIRECTORY);
match file_exists(&dir, &filename) {
Ok(_) => {
@@ -209,8 +222,8 @@ mod tests {
}
#[test]
fn test_get_year() {
let filename = String::from("track01.flac");
let dir = util::test_file_directory();
let filename = util::get_filename(1);
let dir = String::from(util::TESTFILEDIRECTORY);
match file_exists(&dir, &filename) {
Ok(_) => {
@@ -234,8 +247,8 @@ mod tests {
#[test]
fn test_get_track() {
let filename = String::from("track01.flac");
let dir = util::test_file_directory();
let filename = util::get_filename(1);
let dir = String::from(util::TESTFILEDIRECTORY);
match file_exists(&dir, &filename) {
Ok(_) => {
@@ -259,8 +272,8 @@ mod tests {
#[test]
fn test_get_disc() {
let filename = String::from("track01.flac");
let dir = util::test_file_directory();
let filename = util::get_filename(1);
let dir = String::from(util::TESTFILEDIRECTORY);
match file_exists(&dir, &filename) {
Ok(_) => {