Code formatting
This commit is contained in:
@@ -1,29 +1,29 @@
|
||||
mod song_tests {
|
||||
// use std::fs::{self, File};
|
||||
use std::fs;
|
||||
use std::fs::File;
|
||||
use std::io::{Read, Write};
|
||||
use std::path::Path;
|
||||
// use std::fs::{self, File};
|
||||
use std::fs;
|
||||
use std::fs::File;
|
||||
use std::io::{Read, Write};
|
||||
use std::path::Path;
|
||||
|
||||
use tempfile::tempdir;
|
||||
use tempfile::tempdir;
|
||||
|
||||
use icarus_models::song;
|
||||
use icarus_models::types;
|
||||
use icarus_models::song;
|
||||
use icarus_models::types;
|
||||
|
||||
fn get_tests_directory() -> String {
|
||||
fn get_tests_directory() -> String {
|
||||
String::from(env!("CARGO_MANIFEST_DIR").to_owned() + "/tests/")
|
||||
}
|
||||
}
|
||||
|
||||
fn does_directory_exists(directory: &String) -> bool {
|
||||
fn does_directory_exists(directory: &String) -> bool {
|
||||
let path = Path::new(directory);
|
||||
if let Ok(dir_i) = fs::metadata(path) {
|
||||
dir_i.is_dir()
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn extract_data_from_file(filepath: &String) -> Result<Vec<u8>, std::io::Error> {
|
||||
fn extract_data_from_file(filepath: &String) -> Result<Vec<u8>, std::io::Error> {
|
||||
match std::fs::File::open(filepath) {
|
||||
Ok(mut file) => {
|
||||
let mut buffer: Vec<u8> = Vec::new();
|
||||
@@ -37,10 +37,10 @@ fn extract_data_from_file(filepath: &String) -> Result<Vec<u8>, std::io::Error>
|
||||
Err(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_song_to_data() {
|
||||
#[test]
|
||||
fn test_song_to_data() {
|
||||
println!("Test");
|
||||
let some_val = true;
|
||||
|
||||
@@ -103,10 +103,10 @@ fn test_song_to_data() {
|
||||
assert!(false, "Could not get song path: {:?}", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_song_path_check() {
|
||||
#[test]
|
||||
fn test_song_path_check() {
|
||||
let mut song = song::Song::default();
|
||||
song.directory = get_tests_directory();
|
||||
song.filename = String::from("track01.flac");
|
||||
@@ -115,10 +115,10 @@ fn test_song_path_check() {
|
||||
does_directory_exists(&song.directory),
|
||||
"Directory does not exist"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_song_generate_filename() {
|
||||
#[test]
|
||||
fn test_song_generate_filename() {
|
||||
let mut song = song::Song::default();
|
||||
song.directory = get_tests_directory();
|
||||
song.filename = String::from("track01.flac");
|
||||
@@ -135,7 +135,8 @@ fn test_song_generate_filename() {
|
||||
|
||||
assert_eq!(song.directory.is_empty(), false);
|
||||
// song_cpy.directory = String::from(temp_dir.path().to_str());
|
||||
song_cpy.filename = song.generate_filename(types::MusicTypes::FlacExtension, true);
|
||||
song_cpy.filename =
|
||||
song.generate_filename(types::MusicTypes::FlacExtension, true);
|
||||
println!("Directory: {:?}", song_cpy.directory);
|
||||
println!("File to be created: {:?}", song_cpy.filename);
|
||||
|
||||
@@ -164,5 +165,5 @@ fn test_song_generate_filename() {
|
||||
assert!(false, "Error extracting song data: {:?}", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user