Commit 4c071328 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

MediaLibrary: Add an artists() getter

parent 0a9d5b9a
......@@ -259,6 +259,12 @@ ArtistPtr MediaLibrary::createArtist( const std::string& name )
return Artist::create( m_dbConnection, name );
}
std::vector<ArtistPtr> MediaLibrary::artists() const
{
static const std::string req = "SELECT * FROM " + policy::ArtistTable::Name;
return sqlite::Tools::fetchAll<Artist, IArtist>( m_dbConnection, req );
}
void MediaLibrary::addMetadataService(std::unique_ptr<IMetadataService> service)
{
if ( service->initialize( m_parser.get(), this ) == false )
......
......@@ -45,6 +45,7 @@ class MediaLibrary : public IMediaLibrary, public IDiscovererCb
virtual ArtistPtr artist( const std::string& name ) override;
virtual ArtistPtr createArtist( const std::string& name ) override;
virtual std::vector<ArtistPtr> artists() const override;
virtual void discover( const std::string& entryPoint ) override;
// IDiscovererCb implementation
......
......@@ -59,3 +59,19 @@ TEST_F( Artists, Albums )
albums = artist->albums();
ASSERT_EQ( albums.size(), 2u );
}
TEST_F( Artists, GetAll )
{
for ( int i = 0; i < 5; i++ )
{
auto a = ml->createArtist( std::to_string( i ) );
ASSERT_NE( a, nullptr );
}
auto artists = ml->artists();
ASSERT_EQ( artists.size(), 5u );
Reload();
artists = ml->artists();
ASSERT_EQ( artists.size(), 5u );
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment