Added function to make coverart init easier #24

Merged
phoenix merged 4 commits from add_coverart_init into devel 2025-04-04 02:21:31 +00:00
2 changed files with 28 additions and 0 deletions
Showing only changes of commit f772cc8f19 - Show all commits

View File

@@ -10,6 +10,32 @@ pub struct CoverArt {
pub data: Vec<u8>, 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 { impl CoverArt {
pub fn to_data(&self) -> Result<Vec<u8>, std::io::Error> { pub fn to_data(&self) -> Result<Vec<u8>, std::io::Error> {
let path: &String = &self.path; let path: &String = &self.path;

View File

@@ -28,6 +28,7 @@ mod utils {
} }
} }
#[cfg(test)]
mod song_tests { mod song_tests {
use std::fs::File; use std::fs::File;
use std::io::Write; use std::io::Write;
@@ -151,6 +152,7 @@ mod song_tests {
} }
} }
#[cfg(test)]
mod album_tests { mod album_tests {
use crate::utils; use crate::utils;