2023-04-09 22:56:12 +02:00
|
|
|
use std::fs;
|
|
|
|
|
|
|
|
use musichoard::{
|
|
|
|
library::{
|
|
|
|
beets::{Beets, SystemExecutor},
|
|
|
|
Library, Query, QueryOption,
|
|
|
|
},
|
|
|
|
Artist,
|
|
|
|
};
|
|
|
|
|
|
|
|
use crate::COLLECTION;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_no_config_list() {
|
2023-04-10 00:00:06 +02:00
|
|
|
let executor = SystemExecutor::default();
|
2023-04-09 22:56:12 +02:00
|
|
|
|
|
|
|
let mut beets = Beets::new(Box::new(executor));
|
|
|
|
let output = beets.list(&Query::default()).unwrap();
|
|
|
|
|
|
|
|
let expected: Vec<Artist> = vec![];
|
|
|
|
assert_eq!(output, expected);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_full_list() {
|
2023-04-10 00:00:06 +02:00
|
|
|
let executor = SystemExecutor::default().config(Some(
|
|
|
|
&fs::canonicalize("./tests/files/library/config.yml").unwrap(),
|
|
|
|
));
|
2023-04-09 22:56:12 +02:00
|
|
|
|
|
|
|
let mut beets = Beets::new(Box::new(executor));
|
|
|
|
let output = beets.list(&Query::default()).unwrap();
|
|
|
|
|
|
|
|
let expected: Vec<Artist> = COLLECTION.to_owned();
|
|
|
|
assert_eq!(output, expected);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_album_artist_query() {
|
2023-04-10 00:00:06 +02:00
|
|
|
let executor = SystemExecutor::default().config(Some(
|
|
|
|
&fs::canonicalize("./tests/files/library/config.yml").unwrap(),
|
|
|
|
));
|
2023-04-09 22:56:12 +02:00
|
|
|
|
|
|
|
let mut beets = Beets::new(Box::new(executor));
|
|
|
|
let output = beets
|
|
|
|
.list(&Query::default().album_artist(QueryOption::Include(String::from("Аркона"))))
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
let expected: Vec<Artist> = COLLECTION[0..1].to_owned();
|
|
|
|
assert_eq!(output, expected);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_album_title_query() {
|
2023-04-10 00:00:06 +02:00
|
|
|
let executor = SystemExecutor::default().config(Some(
|
|
|
|
&fs::canonicalize("./tests/files/library/config.yml").unwrap(),
|
|
|
|
));
|
2023-04-09 22:56:12 +02:00
|
|
|
|
|
|
|
let mut beets = Beets::new(Box::new(executor));
|
|
|
|
let output = beets
|
|
|
|
.list(&Query::default().album_title(QueryOption::Include(String::from("Slovo"))))
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
let expected: Vec<Artist> = COLLECTION[0..1].to_owned();
|
|
|
|
assert_eq!(output, expected);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_exclude_query() {
|
2023-04-10 00:00:06 +02:00
|
|
|
let executor = SystemExecutor::default().config(Some(
|
|
|
|
&fs::canonicalize("./tests/files/library/config.yml").unwrap(),
|
|
|
|
));
|
2023-04-09 22:56:12 +02:00
|
|
|
|
|
|
|
let mut beets = Beets::new(Box::new(executor));
|
|
|
|
let output = beets
|
|
|
|
.list(&Query::default().album_artist(QueryOption::Exclude(String::from("Аркона"))))
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
let expected: Vec<Artist> = COLLECTION[1..].to_owned();
|
|
|
|
assert_eq!(output, expected);
|
|
|
|
}
|