mirror of
https://github.com/tsirysndr/music-player.git
synced 2026-01-09 13:18:05 -05:00
[storage] fix tests
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
use extism_pdk::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub mod library;
|
||||
pub mod player;
|
||||
pub mod types;
|
||||
|
||||
|
||||
7
pdk/src/library.rs
Normal file
7
pdk/src/library.rs
Normal file
@@ -0,0 +1,7 @@
|
||||
pub struct Library;
|
||||
|
||||
pub fn library() -> Library {
|
||||
Library
|
||||
}
|
||||
|
||||
impl Library {}
|
||||
@@ -76,7 +76,7 @@ impl AlbumSearcher {
|
||||
cover => album.cover.unwrap_or_default().clone()
|
||||
);
|
||||
|
||||
let mut writer = self.index.writer_with_num_threads(64, 192_000_000).unwrap();
|
||||
let mut writer = self.index.writer_with_num_threads(64, 192_000_000)?;
|
||||
writer.add_document(doc)?;
|
||||
writer.commit()?;
|
||||
Ok(())
|
||||
|
||||
@@ -27,9 +27,9 @@ async fn insert_album() {
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
searcher.insert_album(album).unwrap();
|
||||
|
||||
sleep(Duration::from_secs(1)).await;
|
||||
while searcher.insert_album(album.clone()).is_err() {
|
||||
sleep(Duration::from_secs(1)).await;
|
||||
}
|
||||
|
||||
assert!(searcher.search_album("Eternal").is_ok());
|
||||
}
|
||||
@@ -74,9 +74,10 @@ async fn search_album() {
|
||||
artist_id: Some("0afe1226a5a75408acb57e97bd5feca1".to_owned()),
|
||||
..Default::default()
|
||||
};
|
||||
searcher.insert_album(album).unwrap();
|
||||
|
||||
sleep(Duration::from_secs(1)).await;
|
||||
while searcher.insert_album(album.clone()).is_err() {
|
||||
sleep(Duration::from_secs(1)).await;
|
||||
}
|
||||
|
||||
let albums = searcher.search_album("eternal").unwrap();
|
||||
assert_eq!(albums.len(), 1);
|
||||
@@ -91,9 +92,9 @@ async fn search_artist() {
|
||||
name: "Lil Uzi Vert".to_owned(),
|
||||
..Default::default()
|
||||
};
|
||||
searcher.insert_artist(artist).unwrap();
|
||||
|
||||
sleep(Duration::from_secs(1)).await;
|
||||
while searcher.insert_artist(artist.clone()).is_err() {
|
||||
sleep(Duration::from_secs(1)).await;
|
||||
}
|
||||
|
||||
let artists = searcher.search_artist("uzi").unwrap();
|
||||
assert_eq!(artists.len(), 1);
|
||||
@@ -110,11 +111,12 @@ async fn search_track() {
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
searcher
|
||||
.insert_song(song, "27234641d4f5f9e0832affa79b9f62d8")
|
||||
.unwrap();
|
||||
|
||||
sleep(Duration::from_secs(1)).await;
|
||||
while searcher
|
||||
.insert_song(song.clone(), "27234641d4f5f9e0832affa79b9f62d8")
|
||||
.is_err()
|
||||
{
|
||||
sleep(Duration::from_secs(1)).await;
|
||||
}
|
||||
|
||||
let tracks = searcher.search_song("futsal").unwrap();
|
||||
assert_eq!(tracks.len(), 1);
|
||||
|
||||
Reference in New Issue
Block a user