Added module in tests
Some checks failed
Rust Build / Check (pull_request) Successful in 26s
Rust Build / Test Suite (pull_request) Failing after 25s
Rust Build / Rustfmt (pull_request) Successful in 25s
Rust Build / Clippy (pull_request) Successful in 26s
Rust Build / build (pull_request) Successful in 26s
Some checks failed
Rust Build / Check (pull_request) Successful in 26s
Rust Build / Test Suite (pull_request) Failing after 25s
Rust Build / Rustfmt (pull_request) Successful in 25s
Rust Build / Clippy (pull_request) Successful in 26s
Rust Build / build (pull_request) Successful in 26s
This commit is contained in:
@@ -1,19 +1,12 @@
|
||||
mod song_tests {
|
||||
mod utils {
|
||||
use std::fs;
|
||||
use std::fs::File;
|
||||
use std::io::{Read, Write};
|
||||
use std::path::Path;
|
||||
|
||||
use tempfile::tempdir;
|
||||
|
||||
use icarus_models::song;
|
||||
use icarus_models::types;
|
||||
|
||||
fn get_tests_directory() -> String {
|
||||
pub fn get_tests_directory() -> String {
|
||||
String::from(env!("CARGO_MANIFEST_DIR").to_owned() + "/tests/")
|
||||
}
|
||||
|
||||
fn does_directory_exists(directory: &String) -> bool {
|
||||
pub fn does_directory_exists(directory: &String) -> bool {
|
||||
let path = Path::new(directory);
|
||||
if let Ok(dir_i) = fs::metadata(path) {
|
||||
dir_i.is_dir()
|
||||
@@ -21,6 +14,18 @@ mod song_tests {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod song_tests {
|
||||
use std::fs::File;
|
||||
use std::io::{Read, Write};
|
||||
|
||||
use tempfile::tempdir;
|
||||
|
||||
use icarus_models::song;
|
||||
use icarus_models::types;
|
||||
|
||||
use crate::utils;
|
||||
|
||||
fn extract_data_from_file(filepath: &String) -> Result<Vec<u8>, std::io::Error> {
|
||||
match std::fs::File::open(filepath) {
|
||||
@@ -43,11 +48,11 @@ mod song_tests {
|
||||
|
||||
println!("Getting track");
|
||||
let mut song = song::Song::default();
|
||||
song.directory = get_tests_directory();
|
||||
song.directory = utils::get_tests_directory();
|
||||
song.filename = String::from("track01.flac");
|
||||
|
||||
assert!(
|
||||
does_directory_exists(&song.directory),
|
||||
utils::does_directory_exists(&song.directory),
|
||||
"Directory does not exist"
|
||||
);
|
||||
|
||||
@@ -81,11 +86,11 @@ mod song_tests {
|
||||
#[test]
|
||||
fn test_song_path_check() {
|
||||
let mut song = song::Song::default();
|
||||
song.directory = get_tests_directory();
|
||||
song.directory = utils::get_tests_directory();
|
||||
song.filename = String::from("track01.flac");
|
||||
|
||||
assert!(
|
||||
does_directory_exists(&song.directory),
|
||||
utils::does_directory_exists(&song.directory),
|
||||
"Directory does not exist"
|
||||
);
|
||||
}
|
||||
@@ -93,7 +98,7 @@ mod song_tests {
|
||||
#[test]
|
||||
fn test_song_generate_filename() {
|
||||
let mut song = song::Song::default();
|
||||
song.directory = get_tests_directory();
|
||||
song.directory = utils::get_tests_directory();
|
||||
song.filename = String::from("track01.flac");
|
||||
|
||||
match song.song_path() {
|
||||
@@ -144,3 +149,15 @@ mod song_tests {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod album_tests {
|
||||
|
||||
use crate::utils;
|
||||
use icarus_models::album;
|
||||
|
||||
#[test]
|
||||
fn parse_album() {
|
||||
let test_dir = utils::get_tests_directory();
|
||||
if utils::does_directory_exists(&test_dir) {}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user