Added function to make coverart init easier #24
@@ -10,6 +10,32 @@ pub struct CoverArt {
|
||||
pub data: Vec<u8>,
|
||||
}
|
||||
|
||||
pub mod init {
|
||||
use crate::coverart::CoverArt;
|
||||
|
||||
pub fn init_coverart_only_path(path: &String) -> CoverArt {
|
||||
CoverArt {
|
||||
id: uuid::Uuid::new_v4(),
|
||||
title: String::new(),
|
||||
path: path.clone(),
|
||||
data: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::coverart;
|
||||
|
||||
#[test]
|
||||
fn test_cover_art_image() {
|
||||
let path: String = String::from("somepath");
|
||||
let coverart = coverart::init::init_coverart_only_path(&path);
|
||||
|
||||
assert_eq!(path, coverart.path);
|
||||
}
|
||||
}
|
||||
|
||||
impl CoverArt {
|
||||
pub fn to_data(&self) -> Result<Vec<u8>, std::io::Error> {
|
||||
let path: &String = &self.path;
|
||||
|
@@ -28,6 +28,7 @@ mod utils {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod song_tests {
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
@@ -151,6 +152,7 @@ mod song_tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod album_tests {
|
||||
|
||||
use crate::utils;
|
||||
|
Reference in New Issue
Block a user