Commit 9e81e199 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen
Browse files

AlbumTrack: Handle setting genre

parent 9f465028
......@@ -12,6 +12,7 @@ class IAlbumTrack
virtual unsigned int id() const = 0;
virtual const std::string& genre() = 0;
virtual bool setGenre( const std::string& genre ) = 0;
virtual const std::string& title() = 0;
virtual unsigned int trackNumber() = 0;
virtual std::shared_ptr<IAlbum> album() = 0;
......
......@@ -62,6 +62,16 @@ const std::string& AlbumTrack::genre()
return m_genre;
}
bool AlbumTrack::setGenre(const std::string& genre)
{
static const std::string req = "UPDATE " + policy::AlbumTrackTable::Name
+ " SET genre = ? WHERE id_track = ? ";
if ( SqliteTools::executeUpdate( m_dbConnection, req, genre, m_id ) == false )
return false;
m_genre = genre;
return true;
}
const std::string& AlbumTrack::title()
{
return m_title;
......
......@@ -31,6 +31,7 @@ class AlbumTrack : public IAlbumTrack, public Cache<AlbumTrack, IAlbumTrack, pol
virtual unsigned int id() const;
virtual const std::string& genre();
virtual bool setGenre( const std::string& genre );
virtual const std::string& title();
virtual unsigned int trackNumber();
virtual std::shared_ptr<IAlbum> album();
......
......@@ -106,3 +106,20 @@ TEST_F( Albums, DeleteTrack )
auto f2 = ml->file( "file" );
ASSERT_EQ( f2, nullptr );
}
TEST_F( Albums, SetGenre )
{
auto a = ml->createAlbum( "album" );
auto t = a->addTrack( "track", 1 );
t->setGenre( "happy underground post progressive death metal" );
delete ml;
SetUp();
std::vector<AlbumTrackPtr> tracks;
a->tracks( tracks );
auto t2 = tracks[0];
ASSERT_EQ( t->genre(), t2->genre() );
}
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