Merge is feature complete
This commit is contained in:
parent
d20a9a9dec
commit
bbf37c8715
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
/target
|
/target
|
||||||
/codecov
|
/codecov
|
||||||
|
database.json
|
||||||
|
@ -6,13 +6,19 @@ use serde::Serialize;
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
use mockall::automock;
|
use mockall::automock;
|
||||||
|
|
||||||
use super::{Error, IDatabase};
|
use super::{IDatabase, LoadError, SaveError};
|
||||||
|
|
||||||
pub mod backend;
|
pub mod backend;
|
||||||
|
|
||||||
impl From<serde_json::Error> for Error {
|
impl From<serde_json::Error> for LoadError {
|
||||||
fn from(err: serde_json::Error) -> Error {
|
fn from(err: serde_json::Error) -> LoadError {
|
||||||
Error::SerDeError(err.to_string())
|
LoadError::SerDeError(err.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<serde_json::Error> for SaveError {
|
||||||
|
fn from(err: serde_json::Error) -> SaveError {
|
||||||
|
SaveError::SerDeError(err.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,13 +46,13 @@ impl<JDB: IJsonDatabaseBackend> JsonDatabase<JDB> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<JDB: IJsonDatabaseBackend> IDatabase for JsonDatabase<JDB> {
|
impl<JDB: IJsonDatabaseBackend> IDatabase for JsonDatabase<JDB> {
|
||||||
fn read<D: DeserializeOwned>(&self, collection: &mut D) -> Result<(), Error> {
|
fn load<D: DeserializeOwned>(&self, collection: &mut D) -> Result<(), LoadError> {
|
||||||
let serialized = self.backend.read()?;
|
let serialized = self.backend.read()?;
|
||||||
*collection = serde_json::from_str(&serialized)?;
|
*collection = serde_json::from_str(&serialized)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write<S: Serialize>(&mut self, collection: &S) -> Result<(), Error> {
|
fn save<S: Serialize>(&mut self, collection: &S) -> Result<(), SaveError> {
|
||||||
let serialized = serde_json::to_string(&collection)?;
|
let serialized = serde_json::to_string(&collection)?;
|
||||||
self.backend.write(&serialized)?;
|
self.backend.write(&serialized)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -73,8 +79,8 @@ mod tests {
|
|||||||
|
|
||||||
let mut tracks: Vec<String> = vec![];
|
let mut tracks: Vec<String> = vec![];
|
||||||
for track in album.tracks.iter() {
|
for track in album.tracks.iter() {
|
||||||
let track_number = track.number;
|
let track_number = track.id.number;
|
||||||
let track_title = &track.title;
|
let track_title = &track.id.title;
|
||||||
|
|
||||||
let mut track_artist: Vec<String> = vec![];
|
let mut track_artist: Vec<String> = vec![];
|
||||||
for artist in track.artist.iter() {
|
for artist in track.artist.iter() {
|
||||||
@ -89,8 +95,7 @@ mod tests {
|
|||||||
|
|
||||||
tracks.push(format!(
|
tracks.push(format!(
|
||||||
"{{\
|
"{{\
|
||||||
\"number\":{track_number},\
|
\"id\":{{\"number\":{track_number},\"title\":\"{track_title}\"}},\
|
||||||
\"title\":\"{track_title}\",\
|
|
||||||
\"artist\":[{track_artist}],\
|
\"artist\":[{track_artist}],\
|
||||||
\"quality\":{{\"format\":\"{track_format}\",\"bitrate\":{track_bitrate}}}\
|
\"quality\":{{\"format\":\"{track_format}\",\"bitrate\":{track_bitrate}}}\
|
||||||
}}"
|
}}"
|
||||||
@ -128,7 +133,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn write() {
|
fn save() {
|
||||||
let write_data = COLLECTION.to_owned();
|
let write_data = COLLECTION.to_owned();
|
||||||
let input = artists_to_json(&write_data);
|
let input = artists_to_json(&write_data);
|
||||||
|
|
||||||
@ -139,11 +144,11 @@ mod tests {
|
|||||||
.times(1)
|
.times(1)
|
||||||
.return_once(|_| Ok(()));
|
.return_once(|_| Ok(()));
|
||||||
|
|
||||||
JsonDatabase::new(backend).write(&write_data).unwrap();
|
JsonDatabase::new(backend).save(&write_data).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn read() {
|
fn load() {
|
||||||
let expected = COLLECTION.to_owned();
|
let expected = COLLECTION.to_owned();
|
||||||
let result = Ok(artists_to_json(&expected));
|
let result = Ok(artists_to_json(&expected));
|
||||||
|
|
||||||
@ -151,7 +156,7 @@ mod tests {
|
|||||||
backend.expect_read().times(1).return_once(|| result);
|
backend.expect_read().times(1).return_once(|| result);
|
||||||
|
|
||||||
let mut read_data: Vec<Artist> = vec![];
|
let mut read_data: Vec<Artist> = vec![];
|
||||||
JsonDatabase::new(backend).read(&mut read_data).unwrap();
|
JsonDatabase::new(backend).load(&mut read_data).unwrap();
|
||||||
|
|
||||||
assert_eq!(read_data, expected);
|
assert_eq!(read_data, expected);
|
||||||
}
|
}
|
||||||
@ -174,8 +179,8 @@ mod tests {
|
|||||||
|
|
||||||
let write_data = COLLECTION.to_owned();
|
let write_data = COLLECTION.to_owned();
|
||||||
let mut read_data: Vec<Artist> = vec![];
|
let mut read_data: Vec<Artist> = vec![];
|
||||||
database.write(&write_data).unwrap();
|
database.save(&write_data).unwrap();
|
||||||
database.read(&mut read_data).unwrap();
|
database.load(&mut read_data).unwrap();
|
||||||
|
|
||||||
assert_eq!(write_data, read_data);
|
assert_eq!(write_data, read_data);
|
||||||
}
|
}
|
||||||
@ -192,7 +197,7 @@ mod tests {
|
|||||||
let serde_err = serde_json::to_string(&object);
|
let serde_err = serde_json::to_string(&object);
|
||||||
assert!(serde_err.is_err());
|
assert!(serde_err.is_err());
|
||||||
|
|
||||||
let serde_err: Error = serde_err.unwrap_err().into();
|
let serde_err: SaveError = serde_err.unwrap_err().into();
|
||||||
assert!(!serde_err.to_string().is_empty());
|
assert!(!serde_err.to_string().is_empty());
|
||||||
assert!(!format!("{:?}", serde_err).is_empty());
|
assert!(!format!("{:?}", serde_err).is_empty());
|
||||||
}
|
}
|
||||||
|
@ -13,36 +13,62 @@ pub mod json;
|
|||||||
/// Trait for interacting with the database.
|
/// Trait for interacting with the database.
|
||||||
#[cfg_attr(test, automock)]
|
#[cfg_attr(test, automock)]
|
||||||
pub trait IDatabase {
|
pub trait IDatabase {
|
||||||
/// Read collection from the database.
|
/// Load collection from the database.
|
||||||
fn read<D: DeserializeOwned + 'static>(&self, collection: &mut D) -> Result<(), Error>;
|
fn load<D: DeserializeOwned + 'static>(&self, collection: &mut D) -> Result<(), LoadError>;
|
||||||
|
|
||||||
/// Write collection to the database.
|
/// Save collection to the database.
|
||||||
fn write<S: Serialize + 'static>(&mut self, collection: &S) -> Result<(), Error>;
|
fn save<S: Serialize + 'static>(&mut self, collection: &S) -> Result<(), SaveError>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Error type for database calls.
|
/// Error type for database calls.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error {
|
pub enum LoadError {
|
||||||
/// The database experienced an I/O error.
|
/// The database experienced an I/O read error.
|
||||||
IoError(String),
|
IoError(String),
|
||||||
/// The database experienced a (de)serialisation error.
|
/// The database experienced a deserialisation error.
|
||||||
SerDeError(String),
|
SerDeError(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for Error {
|
impl fmt::Display for LoadError {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
Self::IoError(ref s) => write!(f, "the database experienced an I/O error: {s}"),
|
Self::IoError(ref s) => write!(f, "the database experienced an I/O read error: {s}"),
|
||||||
Self::SerDeError(ref s) => {
|
Self::SerDeError(ref s) => {
|
||||||
write!(f, "the database experienced a (de)serialisation error: {s}")
|
write!(f, "the database experienced a deserialisation error: {s}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<std::io::Error> for Error {
|
impl From<std::io::Error> for LoadError {
|
||||||
fn from(err: std::io::Error) -> Error {
|
fn from(err: std::io::Error) -> LoadError {
|
||||||
Error::IoError(err.to_string())
|
LoadError::IoError(err.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Error type for database calls.
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum SaveError {
|
||||||
|
/// The database experienced an I/O write error.
|
||||||
|
IoError(String),
|
||||||
|
/// The database experienced a serialisation error.
|
||||||
|
SerDeError(String),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for SaveError {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
match *self {
|
||||||
|
Self::IoError(ref s) => write!(f, "the database experienced an I/O write error: {s}"),
|
||||||
|
Self::SerDeError(ref s) => {
|
||||||
|
write!(f, "the database experienced a serialisation error: {s}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<std::io::Error> for SaveError {
|
||||||
|
fn from(err: std::io::Error) -> SaveError {
|
||||||
|
SaveError::IoError(err.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,11 +76,15 @@ impl From<std::io::Error> for Error {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
use super::Error;
|
use super::{LoadError, SaveError};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn errors() {
|
fn errors() {
|
||||||
let io_err: Error = io::Error::new(io::ErrorKind::Interrupted, "error").into();
|
let io_err: LoadError = io::Error::new(io::ErrorKind::Interrupted, "error").into();
|
||||||
|
assert!(!io_err.to_string().is_empty());
|
||||||
|
assert!(!format!("{:?}", io_err).is_empty());
|
||||||
|
|
||||||
|
let io_err: SaveError = io::Error::new(io::ErrorKind::Interrupted, "error").into();
|
||||||
assert!(!io_err.to_string().is_empty());
|
assert!(!io_err.to_string().is_empty());
|
||||||
assert!(!format!("{:?}", io_err).is_empty());
|
assert!(!format!("{:?}", io_err).is_empty());
|
||||||
}
|
}
|
||||||
|
358
src/lib.rs
358
src/lib.rs
@ -3,10 +3,16 @@
|
|||||||
pub mod database;
|
pub mod database;
|
||||||
pub mod library;
|
pub mod library;
|
||||||
|
|
||||||
use std::fmt;
|
use std::{
|
||||||
|
cmp::Ordering,
|
||||||
|
collections::{HashMap, HashSet},
|
||||||
|
fmt,
|
||||||
|
iter::Peekable,
|
||||||
|
mem,
|
||||||
|
};
|
||||||
|
|
||||||
use database::IDatabase;
|
use database::IDatabase;
|
||||||
use library::{ILibrary, Query};
|
use library::{ILibrary, Item, Query};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
@ -27,17 +33,42 @@ pub struct Quality {
|
|||||||
pub bitrate: u32,
|
pub bitrate: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The track identifier.
|
||||||
|
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
|
pub struct TrackId {
|
||||||
|
pub number: u32,
|
||||||
|
pub title: String,
|
||||||
|
}
|
||||||
|
|
||||||
/// A single track on an album.
|
/// A single track on an album.
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
|
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
|
||||||
pub struct Track {
|
pub struct Track {
|
||||||
pub number: u32,
|
pub id: TrackId,
|
||||||
pub title: String,
|
|
||||||
pub artist: Vec<String>,
|
pub artist: Vec<String>,
|
||||||
pub quality: Quality,
|
pub quality: Quality,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PartialOrd for Track {
|
||||||
|
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
|
||||||
|
self.id.partial_cmp(&other.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Ord for Track {
|
||||||
|
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
|
||||||
|
self.id.cmp(&other.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Merge for Track {
|
||||||
|
fn merge(self, other: Self) -> Self {
|
||||||
|
assert_eq!(self.id, other.id);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// The album identifier.
|
/// The album identifier.
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, Hash)]
|
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, PartialOrd, Ord, Eq, Hash)]
|
||||||
pub struct AlbumId {
|
pub struct AlbumId {
|
||||||
pub year: u32,
|
pub year: u32,
|
||||||
pub title: String,
|
pub title: String,
|
||||||
@ -50,8 +81,28 @@ pub struct Album {
|
|||||||
pub tracks: Vec<Track>,
|
pub tracks: Vec<Track>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PartialOrd for Album {
|
||||||
|
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
|
||||||
|
self.id.partial_cmp(&other.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Ord for Album {
|
||||||
|
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
|
||||||
|
self.id.cmp(&other.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Merge for Album {
|
||||||
|
fn merge(mut self, other: Self) -> Self {
|
||||||
|
assert_eq!(self.id, other.id);
|
||||||
|
self.tracks = MergeSorted::new(self.tracks.into_iter(), other.tracks.into_iter()).collect();
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// The artist identifier.
|
/// The artist identifier.
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, Hash)]
|
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct ArtistId {
|
pub struct ArtistId {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
}
|
}
|
||||||
@ -63,9 +114,79 @@ pub struct Artist {
|
|||||||
pub albums: Vec<Album>,
|
pub albums: Vec<Album>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PartialOrd for Artist {
|
||||||
|
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
|
||||||
|
self.id.partial_cmp(&other.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Ord for Artist {
|
||||||
|
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
|
||||||
|
self.id.cmp(&other.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Merge for Artist {
|
||||||
|
fn merge(mut self, other: Self) -> Self {
|
||||||
|
assert_eq!(self.id, other.id);
|
||||||
|
self.albums = MergeSorted::new(self.albums.into_iter(), other.albums.into_iter()).collect();
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// The collection type. Currently, a collection is a list of artists.
|
/// The collection type. Currently, a collection is a list of artists.
|
||||||
pub type Collection = Vec<Artist>;
|
pub type Collection = Vec<Artist>;
|
||||||
|
|
||||||
|
trait Merge {
|
||||||
|
fn merge(self, other: Self) -> Self;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct MergeSorted<L, R>
|
||||||
|
where
|
||||||
|
L: Iterator<Item = R::Item>,
|
||||||
|
R: Iterator,
|
||||||
|
{
|
||||||
|
left: Peekable<L>,
|
||||||
|
right: Peekable<R>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<L, R> MergeSorted<L, R>
|
||||||
|
where
|
||||||
|
L: Iterator<Item = R::Item>,
|
||||||
|
R: Iterator,
|
||||||
|
{
|
||||||
|
fn new(left: L, right: R) -> MergeSorted<L, R> {
|
||||||
|
MergeSorted {
|
||||||
|
left: left.peekable(),
|
||||||
|
right: right.peekable(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<L, R> Iterator for MergeSorted<L, R>
|
||||||
|
where
|
||||||
|
L: Iterator<Item = R::Item>,
|
||||||
|
R: Iterator,
|
||||||
|
L::Item: Ord + Merge,
|
||||||
|
{
|
||||||
|
type Item = L::Item;
|
||||||
|
|
||||||
|
fn next(&mut self) -> Option<L::Item> {
|
||||||
|
let which = match (self.left.peek(), self.right.peek()) {
|
||||||
|
(Some(l), Some(r)) => l.cmp(r),
|
||||||
|
(Some(_), None) => Ordering::Less,
|
||||||
|
(None, Some(_)) => Ordering::Greater,
|
||||||
|
(None, None) => return None,
|
||||||
|
};
|
||||||
|
|
||||||
|
match which {
|
||||||
|
Ordering::Less => self.left.next(),
|
||||||
|
Ordering::Equal => Some(self.left.next().unwrap().merge(self.right.next().unwrap())),
|
||||||
|
Ordering::Greater => self.right.next(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Error type for `musichoard`.
|
/// Error type for `musichoard`.
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
@ -92,8 +213,14 @@ impl From<library::Error> for Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<database::Error> for Error {
|
impl From<database::LoadError> for Error {
|
||||||
fn from(err: database::Error) -> Error {
|
fn from(err: database::LoadError) -> Error {
|
||||||
|
Error::DatabaseError(err.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<database::SaveError> for Error {
|
||||||
|
fn from(err: database::SaveError) -> Error {
|
||||||
Error::DatabaseError(err.to_string())
|
Error::DatabaseError(err.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -117,18 +244,119 @@ impl<LIB: ILibrary, DB: IDatabase> MusicHoard<LIB, DB> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn rescan_library(&mut self) -> Result<(), Error> {
|
pub fn rescan_library(&mut self) -> Result<(), Error> {
|
||||||
self.collection = self.library.list(&Query::new())?;
|
let items = self.library.list(&Query::new())?;
|
||||||
|
let mut library = Self::items_to_artists(items);
|
||||||
|
Self::sort(&mut library);
|
||||||
|
|
||||||
|
let collection = mem::take(&mut self.collection);
|
||||||
|
self.collection = Self::merge(library, collection);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn load_from_database(&mut self) -> Result<(), Error> {
|
||||||
|
let mut database: Collection = vec![];
|
||||||
|
self.database.load(&mut database)?;
|
||||||
|
Self::sort(&mut database);
|
||||||
|
|
||||||
|
let collection = mem::take(&mut self.collection);
|
||||||
|
self.collection = Self::merge(collection, database);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn save_to_database(&mut self) -> Result<(), Error> {
|
pub fn save_to_database(&mut self) -> Result<(), Error> {
|
||||||
self.database.write(&self.collection)?;
|
self.database.save(&self.collection)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_collection(&self) -> &Collection {
|
pub fn get_collection(&self) -> &Collection {
|
||||||
&self.collection
|
&self.collection
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn sort(collection: &mut [Artist]) {
|
||||||
|
collection.sort_unstable();
|
||||||
|
for artist in collection.iter_mut() {
|
||||||
|
artist.albums.sort_unstable();
|
||||||
|
for album in artist.albums.iter_mut() {
|
||||||
|
album.tracks.sort_unstable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn merge(primary: Vec<Artist>, secondary: Vec<Artist>) -> Vec<Artist> {
|
||||||
|
MergeSorted::new(primary.into_iter(), secondary.into_iter()).collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn items_to_artists(items: Vec<Item>) -> Vec<Artist> {
|
||||||
|
let mut artists: Vec<Artist> = vec![];
|
||||||
|
let mut album_ids = HashMap::<ArtistId, HashSet<AlbumId>>::new();
|
||||||
|
|
||||||
|
for item in items.into_iter() {
|
||||||
|
let artist_id = ArtistId {
|
||||||
|
name: item.album_artist,
|
||||||
|
};
|
||||||
|
|
||||||
|
let album_id = AlbumId {
|
||||||
|
year: item.album_year,
|
||||||
|
title: item.album_title,
|
||||||
|
};
|
||||||
|
|
||||||
|
let track = Track {
|
||||||
|
id: TrackId {
|
||||||
|
number: item.track_number,
|
||||||
|
title: item.track_title,
|
||||||
|
},
|
||||||
|
artist: item.track_artist,
|
||||||
|
quality: Quality {
|
||||||
|
format: item.track_format,
|
||||||
|
bitrate: item.track_bitrate,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
let artist = if album_ids.contains_key(&artist_id) {
|
||||||
|
// Assume results are in some order which means they will likely be grouped by
|
||||||
|
// artist. Therefore, we look from the back since the last inserted artist is most
|
||||||
|
// likely the one we are looking for.
|
||||||
|
artists
|
||||||
|
.iter_mut()
|
||||||
|
.rev()
|
||||||
|
.find(|a| a.id == artist_id)
|
||||||
|
.unwrap()
|
||||||
|
} else {
|
||||||
|
album_ids.insert(artist_id.clone(), HashSet::<AlbumId>::new());
|
||||||
|
artists.push(Artist {
|
||||||
|
id: artist_id.clone(),
|
||||||
|
albums: vec![],
|
||||||
|
});
|
||||||
|
artists.last_mut().unwrap()
|
||||||
|
};
|
||||||
|
|
||||||
|
if album_ids[&artist_id].contains(&album_id) {
|
||||||
|
// Assume results are in some order which means they will likely be grouped by
|
||||||
|
// album. Therefore, we look from the back since the last inserted album is most
|
||||||
|
// likely the one we are looking for.
|
||||||
|
let album = artist
|
||||||
|
.albums
|
||||||
|
.iter_mut()
|
||||||
|
.rev()
|
||||||
|
.find(|a| a.id == album_id)
|
||||||
|
.unwrap();
|
||||||
|
album.tracks.push(track);
|
||||||
|
} else {
|
||||||
|
album_ids
|
||||||
|
.get_mut(&artist_id)
|
||||||
|
.unwrap()
|
||||||
|
.insert(album_id.clone());
|
||||||
|
artist.albums.push(Album {
|
||||||
|
id: album_id,
|
||||||
|
tracks: vec![track],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
artists
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@ -146,13 +374,110 @@ mod tests {
|
|||||||
|
|
||||||
pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| collection!());
|
pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| collection!());
|
||||||
|
|
||||||
|
pub fn artist_to_items(artist: &Artist) -> Vec<Item> {
|
||||||
|
let mut items = vec![];
|
||||||
|
|
||||||
|
for album in artist.albums.iter() {
|
||||||
|
for track in album.tracks.iter() {
|
||||||
|
items.push(Item {
|
||||||
|
album_artist: artist.id.name.clone(),
|
||||||
|
album_year: album.id.year,
|
||||||
|
album_title: album.id.title.clone(),
|
||||||
|
track_number: track.id.number,
|
||||||
|
track_title: track.id.title.clone(),
|
||||||
|
track_artist: track.artist.clone(),
|
||||||
|
track_format: track.quality.format,
|
||||||
|
track_bitrate: track.quality.bitrate,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
items
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn artists_to_items(artists: &[Artist]) -> Vec<Item> {
|
||||||
|
let mut items = vec![];
|
||||||
|
for artist in artists.iter() {
|
||||||
|
items.append(&mut artist_to_items(artist));
|
||||||
|
}
|
||||||
|
items
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn rescan_library_ordered() {
|
||||||
|
let mut library = MockILibrary::new();
|
||||||
|
let database = MockIDatabase::new();
|
||||||
|
|
||||||
|
let library_input = Query::new();
|
||||||
|
let library_result = Ok(artists_to_items(&COLLECTION));
|
||||||
|
|
||||||
|
library
|
||||||
|
.expect_list()
|
||||||
|
.with(predicate::eq(library_input))
|
||||||
|
.times(1)
|
||||||
|
.return_once(|_| library_result);
|
||||||
|
|
||||||
|
let mut music_hoard = MusicHoard::new(library, database);
|
||||||
|
|
||||||
|
music_hoard.rescan_library().unwrap();
|
||||||
|
assert_eq!(music_hoard.get_collection(), &*COLLECTION);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn rescan_library_unordered() {
|
||||||
|
let mut library = MockILibrary::new();
|
||||||
|
let database = MockIDatabase::new();
|
||||||
|
|
||||||
|
let library_input = Query::new();
|
||||||
|
let mut library_result = Ok(artists_to_items(&COLLECTION));
|
||||||
|
|
||||||
|
// Swap the last item with the first.
|
||||||
|
let last = library_result.as_ref().unwrap().len() - 1;
|
||||||
|
library_result.as_mut().unwrap().swap(0, last);
|
||||||
|
|
||||||
|
library
|
||||||
|
.expect_list()
|
||||||
|
.with(predicate::eq(library_input))
|
||||||
|
.times(1)
|
||||||
|
.return_once(|_| library_result);
|
||||||
|
|
||||||
|
let mut music_hoard = MusicHoard::new(library, database);
|
||||||
|
|
||||||
|
music_hoard.rescan_library().unwrap();
|
||||||
|
assert_eq!(music_hoard.get_collection(), &*COLLECTION);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn rescan_library_album_title_year_clash() {
|
||||||
|
let mut library = MockILibrary::new();
|
||||||
|
let database = MockIDatabase::new();
|
||||||
|
|
||||||
|
let mut expected = COLLECTION.to_owned();
|
||||||
|
expected[0].albums[0].id.year = expected[1].albums[0].id.year;
|
||||||
|
expected[0].albums[0].id.title = expected[1].albums[0].id.title.clone();
|
||||||
|
|
||||||
|
let library_input = Query::new();
|
||||||
|
let library_result = Ok(artists_to_items(&expected));
|
||||||
|
|
||||||
|
library
|
||||||
|
.expect_list()
|
||||||
|
.with(predicate::eq(library_input))
|
||||||
|
.times(1)
|
||||||
|
.return_once(|_| library_result);
|
||||||
|
|
||||||
|
let mut music_hoard = MusicHoard::new(library, database);
|
||||||
|
|
||||||
|
music_hoard.rescan_library().unwrap();
|
||||||
|
assert_eq!(music_hoard.get_collection(), &expected);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn read_get_write() {
|
fn read_get_write() {
|
||||||
let mut library = MockILibrary::new();
|
let mut library = MockILibrary::new();
|
||||||
let mut database = MockIDatabase::new();
|
let mut database = MockIDatabase::new();
|
||||||
|
|
||||||
let library_input = Query::new();
|
let library_input = Query::new();
|
||||||
let library_result = Ok(COLLECTION.to_owned());
|
let library_result = Ok(artists_to_items(&COLLECTION));
|
||||||
|
|
||||||
let database_input = COLLECTION.to_owned();
|
let database_input = COLLECTION.to_owned();
|
||||||
let database_result = Ok(());
|
let database_result = Ok(());
|
||||||
@ -164,7 +489,7 @@ mod tests {
|
|||||||
.return_once(|_| library_result);
|
.return_once(|_| library_result);
|
||||||
|
|
||||||
database
|
database
|
||||||
.expect_write()
|
.expect_save()
|
||||||
.with(predicate::eq(database_input))
|
.with(predicate::eq(database_input))
|
||||||
.times(1)
|
.times(1)
|
||||||
.return_once(|_: &Collection| database_result);
|
.return_once(|_: &Collection| database_result);
|
||||||
@ -203,18 +528,19 @@ mod tests {
|
|||||||
let library = MockILibrary::new();
|
let library = MockILibrary::new();
|
||||||
let mut database = MockIDatabase::new();
|
let mut database = MockIDatabase::new();
|
||||||
|
|
||||||
let database_result = Err(database::Error::IoError(String::from("I/O error")));
|
let database_result = Err(database::SaveError::IoError(String::from("I/O error")));
|
||||||
|
|
||||||
database
|
database
|
||||||
.expect_write()
|
.expect_save()
|
||||||
.times(1)
|
.times(1)
|
||||||
.return_once(|_: &Collection| database_result);
|
.return_once(|_: &Collection| database_result);
|
||||||
|
|
||||||
let mut music_hoard = MusicHoard::new(library, database);
|
let mut music_hoard = MusicHoard::new(library, database);
|
||||||
|
|
||||||
let actual_err = music_hoard.save_to_database().unwrap_err();
|
let actual_err = music_hoard.save_to_database().unwrap_err();
|
||||||
let expected_err =
|
let expected_err = Error::DatabaseError(
|
||||||
Error::DatabaseError(database::Error::IoError(String::from("I/O error")).to_string());
|
database::SaveError::IoError(String::from("I/O error")).to_string(),
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(actual_err, expected_err);
|
assert_eq!(actual_err, expected_err);
|
||||||
assert_eq!(actual_err.to_string(), expected_err.to_string());
|
assert_eq!(actual_err.to_string(), expected_err.to_string());
|
||||||
|
@ -1,17 +1,12 @@
|
|||||||
//! Module for interacting with the music library via
|
//! Module for interacting with the music library via
|
||||||
//! [beets](https://beets.readthedocs.io/en/stable/).
|
//! [beets](https://beets.readthedocs.io/en/stable/).
|
||||||
|
|
||||||
use std::{
|
|
||||||
collections::{HashMap, HashSet},
|
|
||||||
str,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
use mockall::automock;
|
use mockall::automock;
|
||||||
|
|
||||||
use crate::{Album, AlbumId, Artist, ArtistId, Format, Quality, Track};
|
use crate::Format;
|
||||||
|
|
||||||
use super::{Error, Field, ILibrary, Query};
|
use super::{Error, Field, ILibrary, Item, Query};
|
||||||
|
|
||||||
pub mod executor;
|
pub mod executor;
|
||||||
|
|
||||||
@ -92,7 +87,7 @@ pub struct BeetsLibrary<BLE> {
|
|||||||
|
|
||||||
trait ILibraryPrivate {
|
trait ILibraryPrivate {
|
||||||
fn list_cmd_and_args(query: &Query) -> Vec<String>;
|
fn list_cmd_and_args(query: &Query) -> Vec<String>;
|
||||||
fn list_to_artists<S: AsRef<str>>(list_output: &[S]) -> Result<Vec<Artist>, Error>;
|
fn list_to_items<S: AsRef<str>>(list_output: &[S]) -> Result<Vec<Item>, Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<BLE: IBeetsLibraryExecutor> BeetsLibrary<BLE> {
|
impl<BLE: IBeetsLibraryExecutor> BeetsLibrary<BLE> {
|
||||||
@ -104,10 +99,10 @@ impl<BLE: IBeetsLibraryExecutor> BeetsLibrary<BLE> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<BLE: IBeetsLibraryExecutor> ILibrary for BeetsLibrary<BLE> {
|
impl<BLE: IBeetsLibraryExecutor> ILibrary for BeetsLibrary<BLE> {
|
||||||
fn list(&mut self, query: &Query) -> Result<Vec<Artist>, Error> {
|
fn list(&mut self, query: &Query) -> Result<Vec<Item>, Error> {
|
||||||
let cmd = Self::list_cmd_and_args(query);
|
let cmd = Self::list_cmd_and_args(query);
|
||||||
let output = self.executor.exec(&cmd)?;
|
let output = self.executor.exec(&cmd)?;
|
||||||
Self::list_to_artists(&output)
|
Self::list_to_items(&output)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,9 +114,8 @@ impl<BLE: IBeetsLibraryExecutor> ILibraryPrivate for BeetsLibrary<BLE> {
|
|||||||
cmd
|
cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
fn list_to_artists<S: AsRef<str>>(list_output: &[S]) -> Result<Vec<Artist>, Error> {
|
fn list_to_items<S: AsRef<str>>(list_output: &[S]) -> Result<Vec<Item>, Error> {
|
||||||
let mut artists: Vec<Artist> = vec![];
|
let mut items: Vec<Item> = vec![];
|
||||||
let mut album_ids = HashMap::<ArtistId, HashSet<AlbumId>>::new();
|
|
||||||
|
|
||||||
for line in list_output.iter().map(|s| s.as_ref()) {
|
for line in list_output.iter().map(|s| s.as_ref()) {
|
||||||
if line.is_empty() {
|
if line.is_empty() {
|
||||||
@ -138,69 +132,31 @@ impl<BLE: IBeetsLibraryExecutor> ILibraryPrivate for BeetsLibrary<BLE> {
|
|||||||
let album_title = split[2].to_string();
|
let album_title = split[2].to_string();
|
||||||
let track_number = split[3].parse::<u32>()?;
|
let track_number = split[3].parse::<u32>()?;
|
||||||
let track_title = split[4].to_string();
|
let track_title = split[4].to_string();
|
||||||
let track_artist = split[5].to_string();
|
let track_artist = split[5]
|
||||||
let track_format = split[6].to_string();
|
.to_string()
|
||||||
let track_bitrate = split[7].trim_end_matches("kbps").parse::<u32>()?;
|
.split("; ")
|
||||||
|
.map(|s| s.to_owned())
|
||||||
let artist_id = ArtistId { name: album_artist };
|
.collect();
|
||||||
|
let track_format = match split[6].to_string().as_str() {
|
||||||
let album_id = AlbumId {
|
|
||||||
year: album_year,
|
|
||||||
title: album_title,
|
|
||||||
};
|
|
||||||
|
|
||||||
let track = Track {
|
|
||||||
number: track_number,
|
|
||||||
title: track_title,
|
|
||||||
artist: track_artist.split("; ").map(|s| s.to_owned()).collect(),
|
|
||||||
quality: Quality {
|
|
||||||
format: match track_format.as_ref() {
|
|
||||||
TRACK_FORMAT_FLAC => Format::Flac,
|
TRACK_FORMAT_FLAC => Format::Flac,
|
||||||
TRACK_FORMAT_MP3 => Format::Mp3,
|
TRACK_FORMAT_MP3 => Format::Mp3,
|
||||||
_ => return Err(Error::Invalid(line.to_string())),
|
_ => return Err(Error::Invalid(line.to_string())),
|
||||||
},
|
|
||||||
bitrate: track_bitrate,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
let track_bitrate = split[7].trim_end_matches("kbps").parse::<u32>()?;
|
||||||
|
|
||||||
let artist = if album_ids.contains_key(&artist_id) {
|
items.push(Item {
|
||||||
// Beets returns results in order so we look from the back.
|
album_artist,
|
||||||
artists
|
album_year,
|
||||||
.iter_mut()
|
album_title,
|
||||||
.rev()
|
track_number,
|
||||||
.find(|a| a.id == artist_id)
|
track_title,
|
||||||
.unwrap()
|
track_artist,
|
||||||
} else {
|
track_format,
|
||||||
album_ids.insert(artist_id.clone(), HashSet::<AlbumId>::new());
|
track_bitrate,
|
||||||
artists.push(Artist {
|
|
||||||
id: artist_id.clone(),
|
|
||||||
albums: vec![],
|
|
||||||
});
|
|
||||||
artists.last_mut().unwrap()
|
|
||||||
};
|
|
||||||
|
|
||||||
if album_ids[&artist_id].contains(&album_id) {
|
|
||||||
// Beets returns results in order so we look from the back.
|
|
||||||
let album = artist
|
|
||||||
.albums
|
|
||||||
.iter_mut()
|
|
||||||
.rev()
|
|
||||||
.find(|a| a.id == album_id)
|
|
||||||
.unwrap();
|
|
||||||
album.tracks.push(track);
|
|
||||||
} else {
|
|
||||||
album_ids
|
|
||||||
.get_mut(&artist_id)
|
|
||||||
.unwrap()
|
|
||||||
.insert(album_id.clone());
|
|
||||||
artist.albums.push(Album {
|
|
||||||
id: album_id,
|
|
||||||
tracks: vec![track],
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Ok(artists)
|
Ok(items)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,45 +164,34 @@ impl<BLE: IBeetsLibraryExecutor> ILibraryPrivate for BeetsLibrary<BLE> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use mockall::predicate;
|
use mockall::predicate;
|
||||||
|
|
||||||
use crate::tests::COLLECTION;
|
use crate::tests::{artists_to_items, COLLECTION};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
fn artist_to_beets_string(artist: &Artist) -> Vec<String> {
|
fn item_to_beets_string(item: &Item) -> String {
|
||||||
let mut strings = vec![];
|
format!(
|
||||||
|
"{album_artist}{sep}{album_year}{sep}{album_title}{sep}\
|
||||||
let album_artist = &artist.id.name;
|
{track_number}{sep}{track_title}{sep}\
|
||||||
|
{track_artist}{sep}{track_format}{sep}{track_bitrate}kbps",
|
||||||
for album in artist.albums.iter() {
|
album_artist = item.album_artist,
|
||||||
let album_year = &album.id.year;
|
album_year = item.album_year,
|
||||||
let album_title = &album.id.title;
|
album_title = item.album_title,
|
||||||
|
track_number = item.track_number,
|
||||||
for track in album.tracks.iter() {
|
track_title = item.track_title,
|
||||||
let track_number = &track.number;
|
track_artist = item.track_artist.join("; "),
|
||||||
let track_title = &track.title;
|
track_format = match item.track_format {
|
||||||
let track_artist = &track.artist.join("; ");
|
|
||||||
let track_format = match track.quality.format {
|
|
||||||
Format::Flac => TRACK_FORMAT_FLAC,
|
Format::Flac => TRACK_FORMAT_FLAC,
|
||||||
Format::Mp3 => TRACK_FORMAT_MP3,
|
Format::Mp3 => TRACK_FORMAT_MP3,
|
||||||
};
|
},
|
||||||
let track_bitrate = track.quality.bitrate;
|
track_bitrate = item.track_bitrate,
|
||||||
|
sep = LIST_FORMAT_SEPARATOR,
|
||||||
strings.push(format!(
|
)
|
||||||
"{album_artist}{0}{album_year}{0}{album_title}{0}\
|
|
||||||
{track_number}{0}{track_title}{0}\
|
|
||||||
{track_artist}{0}{track_format}{0}{track_bitrate}kbps",
|
|
||||||
LIST_FORMAT_SEPARATOR,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
strings
|
fn items_to_beets_strings(items: &[Item]) -> Vec<String> {
|
||||||
}
|
|
||||||
|
|
||||||
fn artists_to_beets_string(artists: &[Artist]) -> Vec<String> {
|
|
||||||
let mut strings = vec![];
|
let mut strings = vec![];
|
||||||
for artist in artists.iter() {
|
for item in items.iter() {
|
||||||
strings.append(&mut artist_to_beets_string(artist));
|
strings.push(item_to_beets_string(item));
|
||||||
}
|
}
|
||||||
strings
|
strings
|
||||||
}
|
}
|
||||||
@ -311,72 +256,15 @@ mod tests {
|
|||||||
let mut beets = BeetsLibrary::new(executor);
|
let mut beets = BeetsLibrary::new(executor);
|
||||||
let output = beets.list(&Query::new()).unwrap();
|
let output = beets.list(&Query::new()).unwrap();
|
||||||
|
|
||||||
let expected: Vec<Artist> = vec![];
|
let expected: Vec<Item> = vec![];
|
||||||
assert_eq!(output, expected);
|
assert_eq!(output, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_list_ordered() {
|
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 = COLLECTION.to_owned();
|
let expected = artists_to_items(&COLLECTION);
|
||||||
let result = Ok(artists_to_beets_string(&expected));
|
let result = Ok(items_to_beets_strings(&expected));
|
||||||
|
|
||||||
let mut executor = MockIBeetsLibraryExecutor::new();
|
|
||||||
executor
|
|
||||||
.expect_exec()
|
|
||||||
.with(predicate::eq(arguments))
|
|
||||||
.times(1)
|
|
||||||
.return_once(|_| result);
|
|
||||||
|
|
||||||
let mut beets = BeetsLibrary::new(executor);
|
|
||||||
let output = beets.list(&Query::new()).unwrap();
|
|
||||||
|
|
||||||
assert_eq!(output, expected);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_list_unordered() {
|
|
||||||
let arguments = vec!["ls".to_string(), LIST_FORMAT_ARG.to_string()];
|
|
||||||
let mut expected = COLLECTION.to_owned();
|
|
||||||
let mut output = artists_to_beets_string(&expected);
|
|
||||||
let last = output.len() - 1;
|
|
||||||
output.swap(0, last);
|
|
||||||
let result = Ok(output);
|
|
||||||
|
|
||||||
// Putting the last track first will make the entire artist come first in the output.
|
|
||||||
expected.rotate_right(1);
|
|
||||||
|
|
||||||
// Same applies to that artists' albums.
|
|
||||||
expected[0].albums.rotate_right(1);
|
|
||||||
|
|
||||||
// Same applies to that album's tracks.
|
|
||||||
expected[0].albums[0].tracks.rotate_right(1);
|
|
||||||
|
|
||||||
// And the original first album's (now the first album of the second artist) tracks first
|
|
||||||
// track comes last.
|
|
||||||
expected[1].albums[0].tracks.rotate_left(1);
|
|
||||||
|
|
||||||
let mut executor = MockIBeetsLibraryExecutor::new();
|
|
||||||
executor
|
|
||||||
.expect_exec()
|
|
||||||
.with(predicate::eq(arguments))
|
|
||||||
.times(1)
|
|
||||||
.return_once(|_| result);
|
|
||||||
|
|
||||||
let mut beets = BeetsLibrary::new(executor);
|
|
||||||
let output = beets.list(&Query::new()).unwrap();
|
|
||||||
|
|
||||||
assert_eq!(output, expected);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_list_album_title_year_clash() {
|
|
||||||
let arguments = vec!["ls".to_string(), LIST_FORMAT_ARG.to_string()];
|
|
||||||
let mut expected = COLLECTION.to_owned();
|
|
||||||
expected[0].albums[0].id.year = expected[1].albums[0].id.year;
|
|
||||||
expected[0].albums[0].id.title = expected[1].albums[0].id.title.clone();
|
|
||||||
let output = artists_to_beets_string(&expected);
|
|
||||||
let result = Ok(output);
|
|
||||||
|
|
||||||
let mut executor = MockIBeetsLibraryExecutor::new();
|
let mut executor = MockIBeetsLibraryExecutor::new();
|
||||||
executor
|
executor
|
||||||
@ -422,15 +310,15 @@ mod tests {
|
|||||||
let mut beets = BeetsLibrary::new(executor);
|
let mut beets = BeetsLibrary::new(executor);
|
||||||
let output = beets.list(&query).unwrap();
|
let output = beets.list(&query).unwrap();
|
||||||
|
|
||||||
let expected: Vec<Artist> = vec![];
|
let expected: Vec<Item> = vec![];
|
||||||
assert_eq!(output, expected);
|
assert_eq!(output, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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 expected = COLLECTION.to_owned();
|
let expected = artists_to_items(&COLLECTION);
|
||||||
let mut output = artists_to_beets_string(&expected);
|
let mut output = items_to_beets_strings(&expected);
|
||||||
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())
|
||||||
@ -455,8 +343,8 @@ 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 expected = COLLECTION.to_owned();
|
let expected = artists_to_items(&COLLECTION);
|
||||||
let mut output = artists_to_beets_string(&expected);
|
let mut output = items_to_beets_strings(&expected);
|
||||||
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())
|
||||||
|
@ -5,7 +5,7 @@ use std::{collections::HashSet, fmt, num::ParseIntError, str::Utf8Error};
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
use mockall::automock;
|
use mockall::automock;
|
||||||
|
|
||||||
use crate::Artist;
|
use crate::Format;
|
||||||
|
|
||||||
#[cfg(feature = "library-beets")]
|
#[cfg(feature = "library-beets")]
|
||||||
pub mod beets;
|
pub mod beets;
|
||||||
@ -14,7 +14,20 @@ pub mod beets;
|
|||||||
#[cfg_attr(test, automock)]
|
#[cfg_attr(test, automock)]
|
||||||
pub trait ILibrary {
|
pub trait ILibrary {
|
||||||
/// List lirbary items that match the a specific query.
|
/// List lirbary items that match the a specific query.
|
||||||
fn list(&mut self, query: &Query) -> Result<Vec<Artist>, Error>;
|
fn list(&mut self, query: &Query) -> Result<Vec<Item>, Error>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// An item from the library. An item corresponds to an individual file (usually a single track).
|
||||||
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
|
pub struct Item {
|
||||||
|
pub album_artist: String,
|
||||||
|
pub album_year: u32,
|
||||||
|
pub album_title: String,
|
||||||
|
pub track_number: u32,
|
||||||
|
pub track_title: String,
|
||||||
|
pub track_artist: Vec<String>,
|
||||||
|
pub track_format: Format,
|
||||||
|
pub track_bitrate: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Individual fields that can be queried on.
|
/// Individual fields that can be queried on.
|
||||||
|
25
src/main.rs
25
src/main.rs
@ -1,6 +1,8 @@
|
|||||||
|
use std::fs::OpenOptions;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::{ffi::OsString, io};
|
use std::{ffi::OsString, io};
|
||||||
|
|
||||||
|
use musichoard::Collection;
|
||||||
use ratatui::{backend::CrosstermBackend, Terminal};
|
use ratatui::{backend::CrosstermBackend, Terminal};
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
|
|
||||||
@ -57,9 +59,28 @@ fn with<LIB: ILibrary, DB: IDatabase>(lib: LIB, db: DB) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// Create the application.
|
|
||||||
let opt = Opt::from_args();
|
let opt = Opt::from_args();
|
||||||
|
|
||||||
|
// Create an empty database file if it does not exist.
|
||||||
|
match OpenOptions::new()
|
||||||
|
.write(true)
|
||||||
|
.create_new(true)
|
||||||
|
.open(&opt.database_file_path)
|
||||||
|
{
|
||||||
|
Ok(f) => {
|
||||||
|
drop(f);
|
||||||
|
JsonDatabase::new(JsonDatabaseFileBackend::new(&opt.database_file_path))
|
||||||
|
.save::<Collection>(&vec![])
|
||||||
|
.expect("failed to create empty database");
|
||||||
|
}
|
||||||
|
Err(e) => match e.kind() {
|
||||||
|
io::ErrorKind::AlreadyExists => {}
|
||||||
|
_ => panic!("failed to access database file"),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the application.
|
||||||
|
let db_exec = JsonDatabaseFileBackend::new(&opt.database_file_path);
|
||||||
if let Some(uri) = opt.beets_ssh_uri {
|
if let Some(uri) = opt.beets_ssh_uri {
|
||||||
let uri = uri.into_string().expect("invalid SSH URI");
|
let uri = uri.into_string().expect("invalid SSH URI");
|
||||||
let beets_config_file_path = opt
|
let beets_config_file_path = opt
|
||||||
@ -70,11 +91,9 @@ fn main() {
|
|||||||
let lib_exec = BeetsLibrarySshExecutor::new(uri)
|
let lib_exec = BeetsLibrarySshExecutor::new(uri)
|
||||||
.expect("failed to initialise beets")
|
.expect("failed to initialise beets")
|
||||||
.config(beets_config_file_path);
|
.config(beets_config_file_path);
|
||||||
let db_exec = JsonDatabaseFileBackend::new(&opt.database_file_path);
|
|
||||||
with(BeetsLibrary::new(lib_exec), JsonDatabase::new(db_exec));
|
with(BeetsLibrary::new(lib_exec), JsonDatabase::new(db_exec));
|
||||||
} else {
|
} else {
|
||||||
let lib_exec = BeetsLibraryProcessExecutor::default().config(opt.beets_config_file_path);
|
let lib_exec = BeetsLibraryProcessExecutor::default().config(opt.beets_config_file_path);
|
||||||
let db_exec = JsonDatabaseFileBackend::new(&opt.database_file_path);
|
|
||||||
with(BeetsLibrary::new(lib_exec), JsonDatabase::new(db_exec));
|
with(BeetsLibrary::new(lib_exec), JsonDatabase::new(db_exec));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,10 @@ macro_rules! collection {
|
|||||||
},
|
},
|
||||||
tracks: vec![
|
tracks: vec![
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 1,
|
number: 1,
|
||||||
title: "track a.a.1".to_string(),
|
title: "track a.a.1".to_string(),
|
||||||
|
},
|
||||||
artist: vec!["artist a.a.1".to_string()],
|
artist: vec!["artist a.a.1".to_string()],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -22,8 +24,10 @@ macro_rules! collection {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 2,
|
number: 2,
|
||||||
title: "track a.a.2".to_string(),
|
title: "track a.a.2".to_string(),
|
||||||
|
},
|
||||||
artist: vec![
|
artist: vec![
|
||||||
"artist a.a.2.1".to_string(),
|
"artist a.a.2.1".to_string(),
|
||||||
"artist a.a.2.2".to_string(),
|
"artist a.a.2.2".to_string(),
|
||||||
@ -34,8 +38,10 @@ macro_rules! collection {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 3,
|
number: 3,
|
||||||
title: "track a.a.3".to_string(),
|
title: "track a.a.3".to_string(),
|
||||||
|
},
|
||||||
artist: vec!["artist a.a.3".to_string()],
|
artist: vec!["artist a.a.3".to_string()],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -51,8 +57,10 @@ macro_rules! collection {
|
|||||||
},
|
},
|
||||||
tracks: vec![
|
tracks: vec![
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 1,
|
number: 1,
|
||||||
title: "track a.b.1".to_string(),
|
title: "track a.b.1".to_string(),
|
||||||
|
},
|
||||||
artist: vec!["artist a.b.1".to_string()],
|
artist: vec!["artist a.b.1".to_string()],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -60,8 +68,10 @@ macro_rules! collection {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 2,
|
number: 2,
|
||||||
title: "track a.b.2".to_string(),
|
title: "track a.b.2".to_string(),
|
||||||
|
},
|
||||||
artist: vec!["artist a.b.2".to_string()],
|
artist: vec!["artist a.b.2".to_string()],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -84,8 +94,10 @@ macro_rules! collection {
|
|||||||
},
|
},
|
||||||
tracks: vec![
|
tracks: vec![
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 1,
|
number: 1,
|
||||||
title: "track b.a.1".to_string(),
|
title: "track b.a.1".to_string(),
|
||||||
|
},
|
||||||
artist: vec!["artist b.a.1".to_string()],
|
artist: vec!["artist b.a.1".to_string()],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Mp3,
|
format: Format::Mp3,
|
||||||
@ -93,8 +105,10 @@ macro_rules! collection {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 2,
|
number: 2,
|
||||||
title: "track b.a.2".to_string(),
|
title: "track b.a.2".to_string(),
|
||||||
|
},
|
||||||
artist: vec![
|
artist: vec![
|
||||||
"artist b.a.2.1".to_string(),
|
"artist b.a.2.1".to_string(),
|
||||||
"artist b.a.2.2".to_string(),
|
"artist b.a.2.2".to_string(),
|
||||||
@ -113,8 +127,10 @@ macro_rules! collection {
|
|||||||
},
|
},
|
||||||
tracks: vec![
|
tracks: vec![
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 1,
|
number: 1,
|
||||||
title: "track b.b.1".to_string(),
|
title: "track b.b.1".to_string(),
|
||||||
|
},
|
||||||
artist: vec!["artist b.b.1".to_string()],
|
artist: vec!["artist b.b.1".to_string()],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -122,8 +138,10 @@ macro_rules! collection {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 2,
|
number: 2,
|
||||||
title: "track b.b.2".to_string(),
|
title: "track b.b.2".to_string(),
|
||||||
|
},
|
||||||
artist: vec![
|
artist: vec![
|
||||||
"artist b.b.2.1".to_string(),
|
"artist b.b.2.1".to_string(),
|
||||||
"artist b.b.2.2".to_string(),
|
"artist b.b.2.2".to_string(),
|
||||||
@ -149,8 +167,10 @@ macro_rules! collection {
|
|||||||
},
|
},
|
||||||
tracks: vec![
|
tracks: vec![
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 1,
|
number: 1,
|
||||||
title: "track c.a.1".to_string(),
|
title: "track c.a.1".to_string(),
|
||||||
|
},
|
||||||
artist: vec!["artist c.a.1".to_string()],
|
artist: vec!["artist c.a.1".to_string()],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Mp3,
|
format: Format::Mp3,
|
||||||
@ -158,8 +178,10 @@ macro_rules! collection {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 2,
|
number: 2,
|
||||||
title: "track c.a.2".to_string(),
|
title: "track c.a.2".to_string(),
|
||||||
|
},
|
||||||
artist: vec![
|
artist: vec![
|
||||||
"artist c.a.2.1".to_string(),
|
"artist c.a.2.1".to_string(),
|
||||||
"artist c.a.2.2".to_string(),
|
"artist c.a.2.2".to_string(),
|
||||||
@ -178,8 +200,10 @@ macro_rules! collection {
|
|||||||
},
|
},
|
||||||
tracks: vec![
|
tracks: vec![
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 1,
|
number: 1,
|
||||||
title: "track c.b.1".to_string(),
|
title: "track c.b.1".to_string(),
|
||||||
|
},
|
||||||
artist: vec!["artist c.b.1".to_string()],
|
artist: vec!["artist c.b.1".to_string()],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -187,8 +211,10 @@ macro_rules! collection {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 2,
|
number: 2,
|
||||||
title: "track c.b.2".to_string(),
|
title: "track c.b.2".to_string(),
|
||||||
|
},
|
||||||
artist: vec![
|
artist: vec![
|
||||||
"artist c.b.2.1".to_string(),
|
"artist c.b.2.1".to_string(),
|
||||||
"artist c.b.2.2".to_string(),
|
"artist c.b.2.2".to_string(),
|
||||||
|
@ -2,11 +2,14 @@ use crossterm::event::{KeyEvent, MouseEvent};
|
|||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::sync::mpsc;
|
use std::sync::mpsc;
|
||||||
|
|
||||||
|
use super::ui::UiError;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum EventError {
|
pub enum EventError {
|
||||||
Send(Event),
|
Send(Event),
|
||||||
Recv,
|
Recv,
|
||||||
Io(std::io::Error),
|
Io(std::io::Error),
|
||||||
|
Ui(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for EventError {
|
impl fmt::Display for EventError {
|
||||||
@ -17,6 +20,9 @@ impl fmt::Display for EventError {
|
|||||||
Self::Io(ref e) => {
|
Self::Io(ref e) => {
|
||||||
write!(f, "an I/O error was triggered during event handling: {e}")
|
write!(f, "an I/O error was triggered during event handling: {e}")
|
||||||
}
|
}
|
||||||
|
Self::Ui(ref s) => {
|
||||||
|
write!(f, "the UI returned an error during event handling: {s}")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -33,6 +39,12 @@ impl From<mpsc::RecvError> for EventError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<UiError> for EventError {
|
||||||
|
fn from(err: UiError) -> EventError {
|
||||||
|
EventError::Ui(err.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub enum Event {
|
pub enum Event {
|
||||||
Key(KeyEvent),
|
Key(KeyEvent),
|
||||||
|
@ -14,7 +14,8 @@ pub trait IEventHandler<UI> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
trait IEventHandlerPrivate<UI> {
|
trait IEventHandlerPrivate<UI> {
|
||||||
fn handle_key_event(ui: &mut UI, key_event: KeyEvent);
|
fn handle_key_event(ui: &mut UI, key_event: KeyEvent) -> Result<(), EventError>;
|
||||||
|
fn quit(ui: &mut UI) -> Result<(), EventError>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct EventHandler {
|
pub struct EventHandler {
|
||||||
@ -31,7 +32,7 @@ impl EventHandler {
|
|||||||
impl<UI: IUi> IEventHandler<UI> for EventHandler {
|
impl<UI: IUi> IEventHandler<UI> for EventHandler {
|
||||||
fn handle_next_event(&self, ui: &mut UI) -> Result<(), EventError> {
|
fn handle_next_event(&self, ui: &mut UI) -> Result<(), EventError> {
|
||||||
match self.events.recv()? {
|
match self.events.recv()? {
|
||||||
Event::Key(key_event) => Self::handle_key_event(ui, key_event),
|
Event::Key(key_event) => Self::handle_key_event(ui, key_event)?,
|
||||||
Event::Mouse(_) => {}
|
Event::Mouse(_) => {}
|
||||||
Event::Resize(_, _) => {}
|
Event::Resize(_, _) => {}
|
||||||
};
|
};
|
||||||
@ -40,16 +41,16 @@ impl<UI: IUi> IEventHandler<UI> for EventHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<UI: IUi> IEventHandlerPrivate<UI> for EventHandler {
|
impl<UI: IUi> IEventHandlerPrivate<UI> for EventHandler {
|
||||||
fn handle_key_event(ui: &mut UI, key_event: KeyEvent) {
|
fn handle_key_event(ui: &mut UI, key_event: KeyEvent) -> Result<(), EventError> {
|
||||||
match key_event.code {
|
match key_event.code {
|
||||||
// Exit application on `ESC` or `q`.
|
// Exit application on `ESC` or `q`.
|
||||||
KeyCode::Esc | KeyCode::Char('q') => {
|
KeyCode::Esc | KeyCode::Char('q') => {
|
||||||
ui.quit();
|
Self::quit(ui)?;
|
||||||
}
|
}
|
||||||
// Exit application on `Ctrl-C`.
|
// Exit application on `Ctrl-C`.
|
||||||
KeyCode::Char('c') | KeyCode::Char('C') => {
|
KeyCode::Char('c') | KeyCode::Char('C') => {
|
||||||
if key_event.modifiers == KeyModifiers::CONTROL {
|
if key_event.modifiers == KeyModifiers::CONTROL {
|
||||||
ui.quit();
|
Self::quit(ui)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Category change.
|
// Category change.
|
||||||
@ -69,6 +70,14 @@ impl<UI: IUi> IEventHandlerPrivate<UI> for EventHandler {
|
|||||||
// Other keys.
|
// Other keys.
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn quit(ui: &mut UI) -> Result<(), EventError> {
|
||||||
|
ui.quit();
|
||||||
|
ui.save()?;
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// GRCOV_EXCL_STOP
|
// GRCOV_EXCL_STOP
|
||||||
|
@ -3,24 +3,26 @@ use musichoard::{database::IDatabase, library::ILibrary, Collection, MusicHoard}
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
use mockall::automock;
|
use mockall::automock;
|
||||||
|
|
||||||
use super::Error;
|
|
||||||
|
|
||||||
#[cfg_attr(test, automock)]
|
#[cfg_attr(test, automock)]
|
||||||
pub trait IMusicHoard {
|
pub trait IMusicHoard {
|
||||||
fn rescan_library(&mut self) -> Result<(), Error>;
|
fn rescan_library(&mut self) -> Result<(), musichoard::Error>;
|
||||||
|
fn load_from_database(&mut self) -> Result<(), musichoard::Error>;
|
||||||
|
fn save_to_database(&mut self) -> Result<(), musichoard::Error>;
|
||||||
fn get_collection(&self) -> &Collection;
|
fn get_collection(&self) -> &Collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<musichoard::Error> for Error {
|
|
||||||
fn from(err: musichoard::Error) -> Error {
|
|
||||||
Error::Lib(err.to_string())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// GRCOV_EXCL_START
|
// GRCOV_EXCL_START
|
||||||
impl<LIB: ILibrary, DB: IDatabase> IMusicHoard for MusicHoard<LIB, DB> {
|
impl<LIB: ILibrary, DB: IDatabase> IMusicHoard for MusicHoard<LIB, DB> {
|
||||||
fn rescan_library(&mut self) -> Result<(), Error> {
|
fn rescan_library(&mut self) -> Result<(), musichoard::Error> {
|
||||||
Ok(MusicHoard::rescan_library(self)?)
|
MusicHoard::rescan_library(self)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn load_from_database(&mut self) -> Result<(), musichoard::Error> {
|
||||||
|
MusicHoard::load_from_database(self)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn save_to_database(&mut self) -> Result<(), musichoard::Error> {
|
||||||
|
MusicHoard::save_to_database(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_collection(&self) -> &Collection {
|
fn get_collection(&self) -> &Collection {
|
||||||
|
@ -25,6 +25,12 @@ pub enum Error {
|
|||||||
ListenerPanic,
|
ListenerPanic,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<musichoard::Error> for Error {
|
||||||
|
fn from(err: musichoard::Error) -> Error {
|
||||||
|
Error::Lib(err.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<io::Error> for Error {
|
impl From<io::Error> for Error {
|
||||||
fn from(err: io::Error) -> Error {
|
fn from(err: io::Error) -> Error {
|
||||||
Error::Io(err.to_string())
|
Error::Io(err.to_string())
|
||||||
@ -174,13 +180,18 @@ mod tests {
|
|||||||
Terminal::new(backend).unwrap()
|
Terminal::new(backend).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ui(collection: Collection) -> Ui<MockIMusicHoard> {
|
pub fn music_hoard(collection: Collection) -> MockIMusicHoard {
|
||||||
let mut music_hoard = MockIMusicHoard::new();
|
let mut music_hoard = MockIMusicHoard::new();
|
||||||
|
|
||||||
|
music_hoard.expect_load_from_database().returning(|| Ok(()));
|
||||||
music_hoard.expect_rescan_library().returning(|| Ok(()));
|
music_hoard.expect_rescan_library().returning(|| Ok(()));
|
||||||
music_hoard.expect_get_collection().return_const(collection);
|
music_hoard.expect_get_collection().return_const(collection);
|
||||||
|
|
||||||
Ui::new(music_hoard).unwrap()
|
music_hoard
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn ui(collection: Collection) -> Ui<MockIMusicHoard> {
|
||||||
|
Ui::new(music_hoard(collection)).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn listener() -> MockIEventListener {
|
fn listener() -> MockIEventListener {
|
||||||
|
104
src/tui/ui.rs
104
src/tui/ui.rs
@ -1,3 +1,5 @@
|
|||||||
|
use std::fmt;
|
||||||
|
|
||||||
use musichoard::{Album, Artist, Collection, Format, Track};
|
use musichoard::{Album, Artist, Collection, Format, Track};
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
@ -9,10 +11,31 @@ use ratatui::{
|
|||||||
|
|
||||||
use super::{lib::IMusicHoard, Error};
|
use super::{lib::IMusicHoard, Error};
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum UiError {
|
||||||
|
Lib(String),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for UiError {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
match *self {
|
||||||
|
Self::Lib(ref s) => write!(f, "the musichoard library returned an error: {s}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<musichoard::Error> for UiError {
|
||||||
|
fn from(err: musichoard::Error) -> UiError {
|
||||||
|
UiError::Lib(err.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub trait IUi {
|
pub trait IUi {
|
||||||
fn is_running(&self) -> bool;
|
fn is_running(&self) -> bool;
|
||||||
fn quit(&mut self);
|
fn quit(&mut self);
|
||||||
|
|
||||||
|
fn save(&mut self) -> Result<(), UiError>;
|
||||||
|
|
||||||
fn increment_category(&mut self);
|
fn increment_category(&mut self);
|
||||||
fn decrement_category(&mut self);
|
fn decrement_category(&mut self);
|
||||||
|
|
||||||
@ -404,7 +427,7 @@ impl<'a, 'b> TrackState<'a, 'b> {
|
|||||||
let list = List::new(
|
let list = List::new(
|
||||||
tracks
|
tracks
|
||||||
.iter()
|
.iter()
|
||||||
.map(|id| ListItem::new(id.title.as_str()))
|
.map(|tr| ListItem::new(tr.id.title.as_str()))
|
||||||
.collect::<Vec<ListItem>>(),
|
.collect::<Vec<ListItem>>(),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -415,9 +438,9 @@ impl<'a, 'b> TrackState<'a, 'b> {
|
|||||||
Artist: {}\n\
|
Artist: {}\n\
|
||||||
Quality: {}",
|
Quality: {}",
|
||||||
track
|
track
|
||||||
.map(|t| t.number.to_string())
|
.map(|t| t.id.number.to_string())
|
||||||
.unwrap_or_else(|| "".to_string()),
|
.unwrap_or_else(|| "".to_string()),
|
||||||
track.map(|t| t.title.as_str()).unwrap_or(""),
|
track.map(|t| t.id.title.as_str()).unwrap_or(""),
|
||||||
track
|
track
|
||||||
.map(|t| t.artist.join("; "))
|
.map(|t| t.artist.join("; "))
|
||||||
.unwrap_or_else(|| "".to_string()),
|
.unwrap_or_else(|| "".to_string()),
|
||||||
@ -440,6 +463,7 @@ impl<'a, 'b> TrackState<'a, 'b> {
|
|||||||
|
|
||||||
impl<MH: IMusicHoard> Ui<MH> {
|
impl<MH: IMusicHoard> Ui<MH> {
|
||||||
pub fn new(mut music_hoard: MH) -> Result<Self, Error> {
|
pub fn new(mut music_hoard: MH) -> Result<Self, Error> {
|
||||||
|
music_hoard.load_from_database()?;
|
||||||
music_hoard.rescan_library()?;
|
music_hoard.rescan_library()?;
|
||||||
let selection = Selection::new(Some(music_hoard.get_collection()));
|
let selection = Selection::new(Some(music_hoard.get_collection()));
|
||||||
Ok(Ui {
|
Ok(Ui {
|
||||||
@ -531,6 +555,11 @@ impl<MH: IMusicHoard> IUi for Ui<MH> {
|
|||||||
self.running = false;
|
self.running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn save(&mut self) -> Result<(), UiError> {
|
||||||
|
self.music_hoard.save_to_database()?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn increment_category(&mut self) {
|
fn increment_category(&mut self) {
|
||||||
self.selection.increment_category();
|
self.selection.increment_category();
|
||||||
}
|
}
|
||||||
@ -603,6 +632,22 @@ mod tests {
|
|||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
pub fn music_hoard(collection: Collection) -> MockIMusicHoard {
|
||||||
|
let mut music_hoard = MockIMusicHoard::new();
|
||||||
|
|
||||||
|
music_hoard
|
||||||
|
.expect_load_from_database()
|
||||||
|
.times(1)
|
||||||
|
.return_once(|| Ok(()));
|
||||||
|
music_hoard
|
||||||
|
.expect_rescan_library()
|
||||||
|
.times(1)
|
||||||
|
.return_once(|| Ok(()));
|
||||||
|
music_hoard.expect_get_collection().return_const(collection);
|
||||||
|
|
||||||
|
music_hoard
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_track_selection() {
|
fn test_track_selection() {
|
||||||
let tracks = &COLLECTION[0].albums[0].tracks;
|
let tracks = &COLLECTION[0].albums[0].tracks;
|
||||||
@ -757,17 +802,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn ui_running() {
|
fn ui_running() {
|
||||||
let mut music_hoard = MockIMusicHoard::new();
|
let mut ui = Ui::new(music_hoard(COLLECTION.to_owned())).unwrap();
|
||||||
|
|
||||||
music_hoard
|
|
||||||
.expect_rescan_library()
|
|
||||||
.times(1)
|
|
||||||
.return_once(|| Ok(()));
|
|
||||||
music_hoard
|
|
||||||
.expect_get_collection()
|
|
||||||
.return_const(COLLECTION.to_owned());
|
|
||||||
|
|
||||||
let mut ui = Ui::new(music_hoard).unwrap();
|
|
||||||
assert!(ui.is_running());
|
assert!(ui.is_running());
|
||||||
|
|
||||||
ui.quit();
|
ui.quit();
|
||||||
@ -776,17 +811,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn ui_modifiers() {
|
fn ui_modifiers() {
|
||||||
let mut music_hoard = MockIMusicHoard::new();
|
let mut ui = Ui::new(music_hoard(COLLECTION.to_owned())).unwrap();
|
||||||
|
|
||||||
music_hoard
|
|
||||||
.expect_rescan_library()
|
|
||||||
.times(1)
|
|
||||||
.return_once(|| Ok(()));
|
|
||||||
music_hoard
|
|
||||||
.expect_get_collection()
|
|
||||||
.return_const(COLLECTION.to_owned());
|
|
||||||
|
|
||||||
let mut ui = Ui::new(music_hoard).unwrap();
|
|
||||||
assert!(ui.is_running());
|
assert!(ui.is_running());
|
||||||
|
|
||||||
assert_eq!(ui.selection.active, Category::Artist);
|
assert_eq!(ui.selection.active, Category::Artist);
|
||||||
@ -875,17 +900,10 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn app_no_tracks() {
|
fn app_no_tracks() {
|
||||||
let mut music_hoard = MockIMusicHoard::new();
|
|
||||||
let mut collection = COLLECTION.to_owned();
|
let mut collection = COLLECTION.to_owned();
|
||||||
collection[0].albums[0].tracks = vec![];
|
collection[0].albums[0].tracks = vec![];
|
||||||
|
|
||||||
music_hoard
|
let mut app = Ui::new(music_hoard(collection)).unwrap();
|
||||||
.expect_rescan_library()
|
|
||||||
.times(1)
|
|
||||||
.return_once(|| Ok(()));
|
|
||||||
music_hoard.expect_get_collection().return_const(collection);
|
|
||||||
|
|
||||||
let mut app = Ui::new(music_hoard).unwrap();
|
|
||||||
assert!(app.is_running());
|
assert!(app.is_running());
|
||||||
|
|
||||||
assert_eq!(app.selection.active, Category::Artist);
|
assert_eq!(app.selection.active, Category::Artist);
|
||||||
@ -911,17 +929,10 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn app_no_albums() {
|
fn app_no_albums() {
|
||||||
let mut music_hoard = MockIMusicHoard::new();
|
|
||||||
let mut collection = COLLECTION.to_owned();
|
let mut collection = COLLECTION.to_owned();
|
||||||
collection[0].albums = vec![];
|
collection[0].albums = vec![];
|
||||||
|
|
||||||
music_hoard
|
let mut app = Ui::new(music_hoard(collection)).unwrap();
|
||||||
.expect_rescan_library()
|
|
||||||
.times(1)
|
|
||||||
.return_once(|| Ok(()));
|
|
||||||
music_hoard.expect_get_collection().return_const(collection);
|
|
||||||
|
|
||||||
let mut app = Ui::new(music_hoard).unwrap();
|
|
||||||
assert!(app.is_running());
|
assert!(app.is_running());
|
||||||
|
|
||||||
assert_eq!(app.selection.active, Category::Artist);
|
assert_eq!(app.selection.active, Category::Artist);
|
||||||
@ -960,16 +971,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn app_no_artists() {
|
fn app_no_artists() {
|
||||||
let mut music_hoard = MockIMusicHoard::new();
|
let mut app = Ui::new(music_hoard(vec![])).unwrap();
|
||||||
let collection = vec![];
|
|
||||||
|
|
||||||
music_hoard
|
|
||||||
.expect_rescan_library()
|
|
||||||
.times(1)
|
|
||||||
.return_once(|| Ok(()));
|
|
||||||
music_hoard.expect_get_collection().return_const(collection);
|
|
||||||
|
|
||||||
let mut app = Ui::new(music_hoard).unwrap();
|
|
||||||
assert!(app.is_running());
|
assert!(app.is_running());
|
||||||
|
|
||||||
assert_eq!(app.selection.active, Category::Artist);
|
assert_eq!(app.selection.active, Category::Artist);
|
||||||
|
@ -16,14 +16,14 @@ static DATABASE_TEST_FILE: Lazy<PathBuf> =
|
|||||||
Lazy::new(|| fs::canonicalize("./tests/files/database/database.json").unwrap());
|
Lazy::new(|| fs::canonicalize("./tests/files/database/database.json").unwrap());
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn write() {
|
fn save() {
|
||||||
let file = NamedTempFile::new().unwrap();
|
let file = NamedTempFile::new().unwrap();
|
||||||
|
|
||||||
let backend = JsonDatabaseFileBackend::new(file.path());
|
let backend = JsonDatabaseFileBackend::new(file.path());
|
||||||
let mut database = JsonDatabase::new(backend);
|
let mut database = JsonDatabase::new(backend);
|
||||||
|
|
||||||
let write_data = COLLECTION.to_owned();
|
let write_data = COLLECTION.to_owned();
|
||||||
database.write(&write_data).unwrap();
|
database.save(&write_data).unwrap();
|
||||||
|
|
||||||
let expected = fs::read_to_string(&*DATABASE_TEST_FILE).unwrap();
|
let expected = fs::read_to_string(&*DATABASE_TEST_FILE).unwrap();
|
||||||
let actual = fs::read_to_string(file.path()).unwrap();
|
let actual = fs::read_to_string(file.path()).unwrap();
|
||||||
@ -32,12 +32,12 @@ fn write() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn read() {
|
fn load() {
|
||||||
let backend = JsonDatabaseFileBackend::new(&*DATABASE_TEST_FILE);
|
let backend = JsonDatabaseFileBackend::new(&*DATABASE_TEST_FILE);
|
||||||
let database = JsonDatabase::new(backend);
|
let database = JsonDatabase::new(backend);
|
||||||
|
|
||||||
let mut read_data: Vec<Artist> = vec![];
|
let mut read_data: Vec<Artist> = vec![];
|
||||||
database.read(&mut read_data).unwrap();
|
database.load(&mut read_data).unwrap();
|
||||||
|
|
||||||
let expected = COLLECTION.to_owned();
|
let expected = COLLECTION.to_owned();
|
||||||
assert_eq!(read_data, expected);
|
assert_eq!(read_data, expected);
|
||||||
@ -51,10 +51,10 @@ fn reverse() {
|
|||||||
let mut database = JsonDatabase::new(backend);
|
let mut database = JsonDatabase::new(backend);
|
||||||
|
|
||||||
let write_data = COLLECTION.to_owned();
|
let write_data = COLLECTION.to_owned();
|
||||||
database.write(&write_data).unwrap();
|
database.save(&write_data).unwrap();
|
||||||
|
|
||||||
let mut read_data: Vec<Artist> = vec![];
|
let mut read_data: Vec<Artist> = vec![];
|
||||||
database.read(&mut read_data).unwrap();
|
database.load(&mut read_data).unwrap();
|
||||||
|
|
||||||
assert_eq!(write_data, read_data);
|
assert_eq!(write_data, read_data);
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
160
tests/lib.rs
160
tests/lib.rs
@ -1,7 +1,7 @@
|
|||||||
mod database;
|
mod database;
|
||||||
mod library;
|
mod library;
|
||||||
|
|
||||||
use musichoard::{Album, AlbumId, Artist, ArtistId, Format, Quality, Track};
|
use musichoard::{Album, AlbumId, Artist, ArtistId, Format, Quality, Track, TrackId};
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
||||||
@ -17,8 +17,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
tracks: vec![
|
tracks: vec![
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 01,
|
number: 01,
|
||||||
title: String::from("Az’"),
|
title: String::from("Az’"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Аркона")],
|
artist: vec![String::from("Аркона")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -26,8 +28,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 02,
|
number: 02,
|
||||||
title: String::from("Arkaim"),
|
title: String::from("Arkaim"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Аркона")],
|
artist: vec![String::from("Аркона")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -35,8 +39,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 03,
|
number: 03,
|
||||||
title: String::from("Bol’no mne"),
|
title: String::from("Bol’no mne"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Аркона")],
|
artist: vec![String::from("Аркона")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -44,8 +50,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 04,
|
number: 04,
|
||||||
title: String::from("Leshiy"),
|
title: String::from("Leshiy"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Аркона")],
|
artist: vec![String::from("Аркона")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -53,8 +61,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 05,
|
number: 05,
|
||||||
title: String::from("Zakliatie"),
|
title: String::from("Zakliatie"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Аркона")],
|
artist: vec![String::from("Аркона")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -62,8 +72,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 06,
|
number: 06,
|
||||||
title: String::from("Predok"),
|
title: String::from("Predok"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Аркона")],
|
artist: vec![String::from("Аркона")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -71,8 +83,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 07,
|
number: 07,
|
||||||
title: String::from("Nikogda"),
|
title: String::from("Nikogda"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Аркона")],
|
artist: vec![String::from("Аркона")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -80,8 +94,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 08,
|
number: 08,
|
||||||
title: String::from("Tam za tumanami"),
|
title: String::from("Tam za tumanami"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Аркона")],
|
artist: vec![String::from("Аркона")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -89,8 +105,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 09,
|
number: 09,
|
||||||
title: String::from("Potomok"),
|
title: String::from("Potomok"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Аркона")],
|
artist: vec![String::from("Аркона")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -98,8 +116,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 10,
|
number: 10,
|
||||||
title: String::from("Slovo"),
|
title: String::from("Slovo"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Аркона")],
|
artist: vec![String::from("Аркона")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -107,8 +127,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 11,
|
number: 11,
|
||||||
title: String::from("Odna"),
|
title: String::from("Odna"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Аркона")],
|
artist: vec![String::from("Аркона")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -116,8 +138,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 12,
|
number: 12,
|
||||||
title: String::from("Vo moiom sadochke…"),
|
title: String::from("Vo moiom sadochke…"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Аркона")],
|
artist: vec![String::from("Аркона")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -125,8 +149,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 13,
|
number: 13,
|
||||||
title: String::from("Stenka na stenku"),
|
title: String::from("Stenka na stenku"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Аркона")],
|
artist: vec![String::from("Аркона")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -134,8 +160,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 14,
|
number: 14,
|
||||||
title: String::from("Zimushka"),
|
title: String::from("Zimushka"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Аркона")],
|
artist: vec![String::from("Аркона")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -157,8 +185,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
tracks: vec![
|
tracks: vec![
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 01,
|
number: 01,
|
||||||
title: String::from("Samon"),
|
title: String::from("Samon"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Eluveitie")],
|
artist: vec![String::from("Eluveitie")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -166,8 +196,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 02,
|
number: 02,
|
||||||
title: String::from("Primordial Breath"),
|
title: String::from("Primordial Breath"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Eluveitie")],
|
artist: vec![String::from("Eluveitie")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -175,8 +207,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 03,
|
number: 03,
|
||||||
title: String::from("Inis Mona"),
|
title: String::from("Inis Mona"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Eluveitie")],
|
artist: vec![String::from("Eluveitie")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -184,8 +218,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 04,
|
number: 04,
|
||||||
title: String::from("Gray Sublime Archon"),
|
title: String::from("Gray Sublime Archon"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Eluveitie")],
|
artist: vec![String::from("Eluveitie")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -193,8 +229,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 05,
|
number: 05,
|
||||||
title: String::from("Anagantios"),
|
title: String::from("Anagantios"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Eluveitie")],
|
artist: vec![String::from("Eluveitie")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -202,8 +240,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 06,
|
number: 06,
|
||||||
title: String::from("Bloodstained Ground"),
|
title: String::from("Bloodstained Ground"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Eluveitie")],
|
artist: vec![String::from("Eluveitie")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -211,8 +251,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 07,
|
number: 07,
|
||||||
title: String::from("The Somber Lay"),
|
title: String::from("The Somber Lay"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Eluveitie")],
|
artist: vec![String::from("Eluveitie")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -220,8 +262,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 08,
|
number: 08,
|
||||||
title: String::from("Slanias Song"),
|
title: String::from("Slanias Song"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Eluveitie")],
|
artist: vec![String::from("Eluveitie")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -229,8 +273,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 09,
|
number: 09,
|
||||||
title: String::from("Giamonios"),
|
title: String::from("Giamonios"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Eluveitie")],
|
artist: vec![String::from("Eluveitie")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -238,8 +284,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 10,
|
number: 10,
|
||||||
title: String::from("Tarvos"),
|
title: String::from("Tarvos"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Eluveitie")],
|
artist: vec![String::from("Eluveitie")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -247,8 +295,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 11,
|
number: 11,
|
||||||
title: String::from("Calling the Rain"),
|
title: String::from("Calling the Rain"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Eluveitie")],
|
artist: vec![String::from("Eluveitie")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -256,8 +306,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 12,
|
number: 12,
|
||||||
title: String::from("Elembivos"),
|
title: String::from("Elembivos"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Eluveitie")],
|
artist: vec![String::from("Eluveitie")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -273,8 +325,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
tracks: vec![
|
tracks: vec![
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 01,
|
number: 01,
|
||||||
title: String::from("Verja Urit an Bitus"),
|
title: String::from("Verja Urit an Bitus"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Eluveitie")],
|
artist: vec![String::from("Eluveitie")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -282,8 +336,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 02,
|
number: 02,
|
||||||
title: String::from("Uis Elveti"),
|
title: String::from("Uis Elveti"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Eluveitie")],
|
artist: vec![String::from("Eluveitie")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -291,8 +347,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 03,
|
number: 03,
|
||||||
title: String::from("Ôrô"),
|
title: String::from("Ôrô"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Eluveitie")],
|
artist: vec![String::from("Eluveitie")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -300,8 +358,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 04,
|
number: 04,
|
||||||
title: String::from("Lament"),
|
title: String::from("Lament"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Eluveitie")],
|
artist: vec![String::from("Eluveitie")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -309,8 +369,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 05,
|
number: 05,
|
||||||
title: String::from("Druid"),
|
title: String::from("Druid"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Eluveitie")],
|
artist: vec![String::from("Eluveitie")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -318,8 +380,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 06,
|
number: 06,
|
||||||
title: String::from("Jêzaïg"),
|
title: String::from("Jêzaïg"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Eluveitie")],
|
artist: vec![String::from("Eluveitie")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -341,8 +405,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
tracks: vec![
|
tracks: vec![
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 01,
|
number: 01,
|
||||||
title: String::from("Intro = Chaos"),
|
title: String::from("Intro = Chaos"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Frontside")],
|
artist: vec![String::from("Frontside")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -350,8 +416,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 02,
|
number: 02,
|
||||||
title: String::from("Modlitwa"),
|
title: String::from("Modlitwa"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Frontside")],
|
artist: vec![String::from("Frontside")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -359,8 +427,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 03,
|
number: 03,
|
||||||
title: String::from("Długa droga z piekła"),
|
title: String::from("Długa droga z piekła"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Frontside")],
|
artist: vec![String::from("Frontside")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -368,8 +438,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 04,
|
number: 04,
|
||||||
title: String::from("Synowie ognia"),
|
title: String::from("Synowie ognia"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Frontside")],
|
artist: vec![String::from("Frontside")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -377,8 +449,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 05,
|
number: 05,
|
||||||
title: String::from("1902"),
|
title: String::from("1902"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Frontside")],
|
artist: vec![String::from("Frontside")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -386,8 +460,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 06,
|
number: 06,
|
||||||
title: String::from("Krew za krew"),
|
title: String::from("Krew za krew"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Frontside")],
|
artist: vec![String::from("Frontside")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -395,8 +471,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 07,
|
number: 07,
|
||||||
title: String::from("Kulminacja"),
|
title: String::from("Kulminacja"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Frontside")],
|
artist: vec![String::from("Frontside")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -404,8 +482,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 08,
|
number: 08,
|
||||||
title: String::from("Judasz"),
|
title: String::from("Judasz"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Frontside")],
|
artist: vec![String::from("Frontside")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -413,8 +493,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 09,
|
number: 09,
|
||||||
title: String::from("Więzy"),
|
title: String::from("Więzy"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Frontside")],
|
artist: vec![String::from("Frontside")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -422,8 +504,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 10,
|
number: 10,
|
||||||
title: String::from("Zagubione dusze"),
|
title: String::from("Zagubione dusze"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Frontside")],
|
artist: vec![String::from("Frontside")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -431,8 +515,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 11,
|
number: 11,
|
||||||
title: String::from("Linia życia"),
|
title: String::from("Linia życia"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Frontside")],
|
artist: vec![String::from("Frontside")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -453,8 +539,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
tracks: vec![
|
tracks: vec![
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 01,
|
number: 01,
|
||||||
title: String::from("Unbreakable"),
|
title: String::from("Unbreakable"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Heaven’s Basement")],
|
artist: vec![String::from("Heaven’s Basement")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Mp3,
|
format: Format::Mp3,
|
||||||
@ -462,8 +550,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 02,
|
number: 02,
|
||||||
title: String::from("Guilt Trips and Sins"),
|
title: String::from("Guilt Trips and Sins"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Heaven’s Basement")],
|
artist: vec![String::from("Heaven’s Basement")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Mp3,
|
format: Format::Mp3,
|
||||||
@ -471,8 +561,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 03,
|
number: 03,
|
||||||
title: String::from("The Long Goodbye"),
|
title: String::from("The Long Goodbye"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Heaven’s Basement")],
|
artist: vec![String::from("Heaven’s Basement")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Mp3,
|
format: Format::Mp3,
|
||||||
@ -480,8 +572,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 04,
|
number: 04,
|
||||||
title: String::from("Close Encounters"),
|
title: String::from("Close Encounters"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Heaven’s Basement")],
|
artist: vec![String::from("Heaven’s Basement")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Mp3,
|
format: Format::Mp3,
|
||||||
@ -489,8 +583,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 05,
|
number: 05,
|
||||||
title: String::from("Paranoia"),
|
title: String::from("Paranoia"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Heaven’s Basement")],
|
artist: vec![String::from("Heaven’s Basement")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Mp3,
|
format: Format::Mp3,
|
||||||
@ -498,8 +594,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 06,
|
number: 06,
|
||||||
title: String::from("Let Me Out of Here"),
|
title: String::from("Let Me Out of Here"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Heaven’s Basement")],
|
artist: vec![String::from("Heaven’s Basement")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Mp3,
|
format: Format::Mp3,
|
||||||
@ -507,8 +605,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 07,
|
number: 07,
|
||||||
title: String::from("Leeches"),
|
title: String::from("Leeches"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Heaven’s Basement")],
|
artist: vec![String::from("Heaven’s Basement")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Mp3,
|
format: Format::Mp3,
|
||||||
@ -530,8 +630,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
tracks: vec![
|
tracks: vec![
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 01,
|
number: 01,
|
||||||
title: String::from("Fight Fire with Fire"),
|
title: String::from("Fight Fire with Fire"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Metallica")],
|
artist: vec![String::from("Metallica")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -539,8 +641,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 02,
|
number: 02,
|
||||||
title: String::from("Ride the Lightning"),
|
title: String::from("Ride the Lightning"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Metallica")],
|
artist: vec![String::from("Metallica")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -548,8 +652,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 03,
|
number: 03,
|
||||||
title: String::from("For Whom the Bell Tolls"),
|
title: String::from("For Whom the Bell Tolls"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Metallica")],
|
artist: vec![String::from("Metallica")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -557,8 +663,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 04,
|
number: 04,
|
||||||
title: String::from("Fade to Black"),
|
title: String::from("Fade to Black"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Metallica")],
|
artist: vec![String::from("Metallica")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -566,8 +674,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 05,
|
number: 05,
|
||||||
title: String::from("Trapped under Ice"),
|
title: String::from("Trapped under Ice"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Metallica")],
|
artist: vec![String::from("Metallica")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -575,8 +685,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 06,
|
number: 06,
|
||||||
title: String::from("Escape"),
|
title: String::from("Escape"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Metallica")],
|
artist: vec![String::from("Metallica")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -584,8 +696,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 07,
|
number: 07,
|
||||||
title: String::from("Creeping Death"),
|
title: String::from("Creeping Death"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Metallica")],
|
artist: vec![String::from("Metallica")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -593,8 +707,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 08,
|
number: 08,
|
||||||
title: String::from("The Call of Ktulu"),
|
title: String::from("The Call of Ktulu"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Metallica")],
|
artist: vec![String::from("Metallica")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -610,8 +726,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
tracks: vec![
|
tracks: vec![
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 01,
|
number: 01,
|
||||||
title: String::from("The Ecstasy of Gold"),
|
title: String::from("The Ecstasy of Gold"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Metallica")],
|
artist: vec![String::from("Metallica")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -619,8 +737,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 02,
|
number: 02,
|
||||||
title: String::from("The Call of Ktulu"),
|
title: String::from("The Call of Ktulu"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Metallica")],
|
artist: vec![String::from("Metallica")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -628,8 +748,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 03,
|
number: 03,
|
||||||
title: String::from("Master of Puppets"),
|
title: String::from("Master of Puppets"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Metallica")],
|
artist: vec![String::from("Metallica")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -637,8 +759,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 04,
|
number: 04,
|
||||||
title: String::from("Of Wolf and Man"),
|
title: String::from("Of Wolf and Man"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Metallica")],
|
artist: vec![String::from("Metallica")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -646,8 +770,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 05,
|
number: 05,
|
||||||
title: String::from("The Thing That Should Not Be"),
|
title: String::from("The Thing That Should Not Be"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Metallica")],
|
artist: vec![String::from("Metallica")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -655,8 +781,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 06,
|
number: 06,
|
||||||
title: String::from("Fuel"),
|
title: String::from("Fuel"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Metallica")],
|
artist: vec![String::from("Metallica")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -664,8 +792,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 07,
|
number: 07,
|
||||||
title: String::from("The Memory Remains"),
|
title: String::from("The Memory Remains"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Metallica")],
|
artist: vec![String::from("Metallica")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -673,8 +803,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 08,
|
number: 08,
|
||||||
title: String::from("No Leaf Clover"),
|
title: String::from("No Leaf Clover"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Metallica")],
|
artist: vec![String::from("Metallica")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -682,8 +814,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 09,
|
number: 09,
|
||||||
title: String::from("Hero of the Day"),
|
title: String::from("Hero of the Day"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Metallica")],
|
artist: vec![String::from("Metallica")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -691,8 +825,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 10,
|
number: 10,
|
||||||
title: String::from("Devil’s Dance"),
|
title: String::from("Devil’s Dance"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Metallica")],
|
artist: vec![String::from("Metallica")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -700,8 +836,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 11,
|
number: 11,
|
||||||
title: String::from("Bleeding Me"),
|
title: String::from("Bleeding Me"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Metallica")],
|
artist: vec![String::from("Metallica")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -709,8 +847,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 12,
|
number: 12,
|
||||||
title: String::from("Nothing Else Matters"),
|
title: String::from("Nothing Else Matters"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Metallica")],
|
artist: vec![String::from("Metallica")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -718,8 +858,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 13,
|
number: 13,
|
||||||
title: String::from("Until It Sleeps"),
|
title: String::from("Until It Sleeps"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Metallica")],
|
artist: vec![String::from("Metallica")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -727,8 +869,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 14,
|
number: 14,
|
||||||
title: String::from("For Whom the Bell Tolls"),
|
title: String::from("For Whom the Bell Tolls"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Metallica")],
|
artist: vec![String::from("Metallica")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -736,8 +880,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 15,
|
number: 15,
|
||||||
title: String::from("−Human"),
|
title: String::from("−Human"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Metallica")],
|
artist: vec![String::from("Metallica")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -745,8 +891,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 16,
|
number: 16,
|
||||||
title: String::from("Wherever I May Roam"),
|
title: String::from("Wherever I May Roam"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Metallica")],
|
artist: vec![String::from("Metallica")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -754,8 +902,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 17,
|
number: 17,
|
||||||
title: String::from("Outlaw Torn"),
|
title: String::from("Outlaw Torn"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Metallica")],
|
artist: vec![String::from("Metallica")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -763,8 +913,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 18,
|
number: 18,
|
||||||
title: String::from("Sad but True"),
|
title: String::from("Sad but True"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Metallica")],
|
artist: vec![String::from("Metallica")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -772,8 +924,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 19,
|
number: 19,
|
||||||
title: String::from("One"),
|
title: String::from("One"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Metallica")],
|
artist: vec![String::from("Metallica")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -781,8 +935,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 20,
|
number: 20,
|
||||||
title: String::from("Enter Sandman"),
|
title: String::from("Enter Sandman"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Metallica")],
|
artist: vec![String::from("Metallica")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
@ -790,8 +946,10 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
|
id: TrackId {
|
||||||
number: 21,
|
number: 21,
|
||||||
title: String::from("Battery"),
|
title: String::from("Battery"),
|
||||||
|
},
|
||||||
artist: vec![String::from("Metallica")],
|
artist: vec![String::from("Metallica")],
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
format: Format::Flac,
|
format: Format::Flac,
|
||||||
|
@ -9,7 +9,7 @@ use once_cell::sync::Lazy;
|
|||||||
use musichoard::{
|
use musichoard::{
|
||||||
library::{
|
library::{
|
||||||
beets::{executor::BeetsLibraryProcessExecutor, BeetsLibrary},
|
beets::{executor::BeetsLibraryProcessExecutor, BeetsLibrary},
|
||||||
Field, ILibrary, Query,
|
Field, ILibrary, Item, Query,
|
||||||
},
|
},
|
||||||
Artist,
|
Artist,
|
||||||
};
|
};
|
||||||
@ -32,6 +32,35 @@ static BEETS_TEST_CONFIG: Lazy<Arc<Mutex<BeetsLibrary<BeetsLibraryProcessExecuto
|
|||||||
)))
|
)))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
fn artist_to_items(artist: &Artist) -> Vec<Item> {
|
||||||
|
let mut items = vec![];
|
||||||
|
|
||||||
|
for album in artist.albums.iter() {
|
||||||
|
for track in album.tracks.iter() {
|
||||||
|
items.push(Item {
|
||||||
|
album_artist: artist.id.name.clone(),
|
||||||
|
album_year: album.id.year,
|
||||||
|
album_title: album.id.title.clone(),
|
||||||
|
track_number: track.id.number,
|
||||||
|
track_title: track.id.title.clone(),
|
||||||
|
track_artist: track.artist.clone(),
|
||||||
|
track_format: track.quality.format,
|
||||||
|
track_bitrate: track.quality.bitrate,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
items
|
||||||
|
}
|
||||||
|
|
||||||
|
fn artists_to_items(artists: &[Artist]) -> Vec<Item> {
|
||||||
|
let mut items = vec![];
|
||||||
|
for artist in artists.iter() {
|
||||||
|
items.append(&mut artist_to_items(artist));
|
||||||
|
}
|
||||||
|
items
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_no_config_list() {
|
fn test_no_config_list() {
|
||||||
let beets_arc = BEETS_EMPTY_CONFIG.clone();
|
let beets_arc = BEETS_EMPTY_CONFIG.clone();
|
||||||
@ -39,7 +68,7 @@ fn test_no_config_list() {
|
|||||||
|
|
||||||
let output = beets.list(&Query::new()).unwrap();
|
let output = beets.list(&Query::new()).unwrap();
|
||||||
|
|
||||||
let expected: Vec<Artist> = vec![];
|
let expected: Vec<Item> = vec![];
|
||||||
assert_eq!(output, expected);
|
assert_eq!(output, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +90,7 @@ fn test_full_list() {
|
|||||||
|
|
||||||
let output = beets.list(&Query::new()).unwrap();
|
let output = beets.list(&Query::new()).unwrap();
|
||||||
|
|
||||||
let expected: Vec<Artist> = COLLECTION.to_owned();
|
let expected: Vec<Item> = artists_to_items(&COLLECTION);
|
||||||
assert_eq!(output, expected);
|
assert_eq!(output, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +103,7 @@ fn test_album_artist_query() {
|
|||||||
.list(Query::new().include(Field::AlbumArtist(String::from("Аркона"))))
|
.list(Query::new().include(Field::AlbumArtist(String::from("Аркона"))))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let expected: Vec<Artist> = COLLECTION[0..1].to_owned();
|
let expected: Vec<Item> = artists_to_items(&COLLECTION[0..1]);
|
||||||
assert_eq!(output, expected);
|
assert_eq!(output, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +116,7 @@ fn test_album_title_query() {
|
|||||||
.list(&Query::new().include(Field::AlbumTitle(String::from("Slovo"))))
|
.list(&Query::new().include(Field::AlbumTitle(String::from("Slovo"))))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let expected: Vec<Artist> = COLLECTION[0..1].to_owned();
|
let expected: Vec<Item> = artists_to_items(&COLLECTION[0..1]);
|
||||||
assert_eq!(output, expected);
|
assert_eq!(output, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,6 +129,6 @@ fn test_exclude_query() {
|
|||||||
.list(&Query::new().exclude(Field::AlbumArtist(String::from("Аркона"))))
|
.list(&Query::new().exclude(Field::AlbumArtist(String::from("Аркона"))))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let expected: Vec<Artist> = COLLECTION[1..].to_owned();
|
let expected: Vec<Item> = artists_to_items(&COLLECTION[1..]);
|
||||||
assert_eq!(output, expected);
|
assert_eq!(output, expected);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user