Formatting
This commit is contained in:
@@ -87,7 +87,10 @@ impl SearchProvider for MockSearch {
|
||||
})
|
||||
}
|
||||
|
||||
async fn get_release_groups(&self, _artist_id: &str) -> SearchResult<Vec<shanty_search::ReleaseGroupResult>> {
|
||||
async fn get_release_groups(
|
||||
&self,
|
||||
_artist_id: &str,
|
||||
) -> SearchResult<Vec<shanty_search::ReleaseGroupResult>> {
|
||||
Ok(vec![])
|
||||
}
|
||||
}
|
||||
@@ -104,14 +107,20 @@ async fn test_search_artist() {
|
||||
#[tokio::test]
|
||||
async fn test_search_artist_no_results() {
|
||||
let provider = MockSearch;
|
||||
let results = provider.search_artist("Nonexistent Band", 10).await.unwrap();
|
||||
let results = provider
|
||||
.search_artist("Nonexistent Band", 10)
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(results.is_empty());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_search_album() {
|
||||
let provider = MockSearch;
|
||||
let results = provider.search_album("Dark Side", Some("Pink Floyd"), 10).await.unwrap();
|
||||
let results = provider
|
||||
.search_album("Dark Side", Some("Pink Floyd"), 10)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(results.len(), 1);
|
||||
assert_eq!(results[0].title, "The Dark Side of the Moon");
|
||||
}
|
||||
@@ -119,10 +128,16 @@ async fn test_search_album() {
|
||||
#[tokio::test]
|
||||
async fn test_search_track() {
|
||||
let provider = MockSearch;
|
||||
let results = provider.search_track("Time", Some("Pink Floyd"), 10).await.unwrap();
|
||||
let results = provider
|
||||
.search_track("Time", Some("Pink Floyd"), 10)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(results.len(), 1);
|
||||
assert_eq!(results[0].title, "Time");
|
||||
assert_eq!(results[0].album.as_deref(), Some("The Dark Side of the Moon"));
|
||||
assert_eq!(
|
||||
results[0].album.as_deref(),
|
||||
Some("The Dark Side of the Moon")
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@@ -162,18 +177,25 @@ async fn test_cache_roundtrip() {
|
||||
}];
|
||||
|
||||
// Cache miss
|
||||
let cached: Option<Vec<ArtistResult>> =
|
||||
cache::get_cached(Some(db.conn()), "test:artist:query").await.unwrap();
|
||||
let cached: Option<Vec<ArtistResult>> = cache::get_cached(Some(db.conn()), "test:artist:query")
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(cached.is_none());
|
||||
|
||||
// Store
|
||||
cache::set_cached(Some(db.conn()), "test:artist:query", "musicbrainz", &results)
|
||||
.await
|
||||
.unwrap();
|
||||
cache::set_cached(
|
||||
Some(db.conn()),
|
||||
"test:artist:query",
|
||||
"musicbrainz",
|
||||
&results,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// Cache hit
|
||||
let cached: Option<Vec<ArtistResult>> =
|
||||
cache::get_cached(Some(db.conn()), "test:artist:query").await.unwrap();
|
||||
let cached: Option<Vec<ArtistResult>> = cache::get_cached(Some(db.conn()), "test:artist:query")
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(cached.is_some());
|
||||
assert_eq!(cached.unwrap()[0].name, "Cached Artist");
|
||||
}
|
||||
@@ -181,8 +203,7 @@ async fn test_cache_roundtrip() {
|
||||
#[tokio::test]
|
||||
async fn test_cache_none_conn() {
|
||||
// With no DB connection, caching is a no-op
|
||||
let cached: Option<Vec<ArtistResult>> =
|
||||
cache::get_cached(None, "anything").await.unwrap();
|
||||
let cached: Option<Vec<ArtistResult>> = cache::get_cached(None, "anything").await.unwrap();
|
||||
assert!(cached.is_none());
|
||||
|
||||
// set_cached with None conn should not error
|
||||
|
||||
Reference in New Issue
Block a user