Separate the collection from beets output in tests #114

Merged
wojtek merged 8 commits from 113---separate-the-collection-from-beets-output-in-tests into main 2024-01-21 15:29:37 +01:00
2 changed files with 6 additions and 6 deletions
Showing only changes of commit 22a21a5cc4 - Show all commits

View File

@ -173,7 +173,7 @@ impl<BLE: IBeetsLibraryExecutor> ILibraryPrivate for BeetsLibrary<BLE> {
mod tests { mod tests {
use mockall::predicate; use mockall::predicate;
use crate::library::testlib::{BEETS_OUTPUT, LIBRARY_ITEMS}; use crate::library::testlib::{LIBRARY_BEETS, LIBRARY_ITEMS};
use super::*; use super::*;
@ -247,7 +247,7 @@ mod tests {
fn test_list() { fn test_list() {
let arguments = vec!["ls".to_string(), LIST_FORMAT_ARG.to_string()]; let arguments = vec!["ls".to_string(), LIST_FORMAT_ARG.to_string()];
let expected: &Vec<Item> = LIBRARY_ITEMS.as_ref(); let expected: &Vec<Item> = LIBRARY_ITEMS.as_ref();
let result = Ok(BEETS_OUTPUT.to_owned()); let result = Ok(LIBRARY_BEETS.to_owned());
let mut executor = MockIBeetsLibraryExecutor::new(); let mut executor = MockIBeetsLibraryExecutor::new();
executor executor
@ -300,7 +300,7 @@ mod tests {
#[test] #[test]
fn invalid_data_split() { fn invalid_data_split() {
let arguments = vec!["ls".to_string(), LIST_FORMAT_ARG.to_string()]; let arguments = vec!["ls".to_string(), LIST_FORMAT_ARG.to_string()];
let mut output: Vec<String> = BEETS_OUTPUT.to_owned(); let mut output: Vec<String> = LIBRARY_BEETS.to_owned();
let invalid_string = output[2] let invalid_string = output[2]
.split(LIST_FORMAT_SEPARATOR) .split(LIST_FORMAT_SEPARATOR)
.map(|s| s.to_owned()) .map(|s| s.to_owned())
@ -325,7 +325,7 @@ mod tests {
#[test] #[test]
fn invalid_data_format() { fn invalid_data_format() {
let arguments = vec!["ls".to_string(), LIST_FORMAT_ARG.to_string()]; let arguments = vec!["ls".to_string(), LIST_FORMAT_ARG.to_string()];
let mut output: Vec<String> = BEETS_OUTPUT.to_owned(); let mut output: Vec<String> = LIBRARY_BEETS.to_owned();
let mut invalid_string = output[2] let mut invalid_string = output[2]
.split(LIST_FORMAT_SEPARATOR) .split(LIST_FORMAT_SEPARATOR)
.map(|s| s.to_owned()) .map(|s| s.to_owned())

View File

@ -3,7 +3,7 @@ use once_cell::sync::Lazy;
use crate::library::Item; use crate::library::Item;
use crate::Format; use crate::Format;
macro_rules! beets_output { macro_rules! library_beets {
() => { () => {
vec![ vec![
String::from("album_artist a -*^- -*^- 1998 -*^- album_title a.a -*^- 1 -*^- track a.a.1 -*^- artist a.a.1 -*^- FLAC -*^- 992"), String::from("album_artist a -*^- -*^- 1998 -*^- album_title a.a -*^- 1 -*^- track a.a.1 -*^- artist a.a.1 -*^- FLAC -*^- 992"),
@ -188,5 +188,5 @@ macro_rules! library_items {
}; };
} }
pub static BEETS_OUTPUT: Lazy<Vec<String>> = Lazy::new(|| beets_output!()); pub static LIBRARY_BEETS: Lazy<Vec<String>> = Lazy::new(|| library_beets!());
pub static LIBRARY_ITEMS: Lazy<Vec<Item>> = Lazy::new(|| library_items!()); pub static LIBRARY_ITEMS: Lazy<Vec<Item>> = Lazy::new(|| library_items!());