Now using new artwork table everywhere in app and subsonic API to refer to artworks

This commit is contained in:
emeric
2025-06-22 16:49:54 +02:00
parent 93b446e124
commit c251c2a924
34 changed files with 475 additions and 478 deletions
+83
View File
@@ -0,0 +1,83 @@
/*
* Copyright (C) 2025of LMS.
*
* LMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Common.hpp"
#include "database/Artwork.hpp"
#include "database/Image.hpp"
#include "database/TrackEmbeddedImage.hpp"
#include "database/TrackEmbeddedImageLink.hpp"
namespace lms::db::tests
{
using ScopedArtwork = ScopedEntity<db::Artwork>;
using ScopedImage = ScopedEntity<db::Image>;
using ScopedTrackEmbeddedImage = ScopedEntity<db::TrackEmbeddedImage>;
TEST_F(DatabaseFixture, Artwork_image)
{
{
auto transaction{ session.createReadTransaction() };
EXPECT_EQ(Artwork::getCount(session), 0);
}
ScopedImage image{ session, "/MyImage" };
ScopedArtwork artwork{ session, image.lockAndGet() };
const Wt::WDateTime dateTime{ Wt::WDate{ 2025, 1, 1 } };
{
auto transaction{ session.createReadTransaction() };
EXPECT_EQ(Artwork::getCount(session), 1);
}
{
auto transaction{ session.createWriteTransaction() };
image.get().modify()->setLastWriteTime(dateTime);
}
{
auto transaction{ session.createReadTransaction() };
EXPECT_EQ(artwork.get()->getLastWrittenTime(), dateTime);
}
}
TEST_F(DatabaseFixture, Artwork_trackEmbeddedImage)
{
{
auto transaction{ session.createReadTransaction() };
EXPECT_EQ(Artwork::getCount(session), 0);
}
ScopedTrackEmbeddedImage image{ session };
ScopedTrack track{ session };
ScopedArtwork artwork{ session, image.lockAndGet() };
const Wt::WDateTime dateTime{ Wt::WDate{ 2025, 1, 1 } };
{
auto transaction{ session.createWriteTransaction() };
session.create<db::TrackEmbeddedImageLink>(track.get(), image.get());
track.get().modify()->setLastWriteTime(dateTime);
}
{
auto transaction{ session.createReadTransaction() };
EXPECT_EQ(artwork.get()->getLastWrittenTime(), dateTime);
}
}
} // namespace lms::db::tests
+1
View File
@@ -2,6 +2,7 @@
add_executable(test-database
Artist.cpp
ArtistInfo.cpp
Artwork.cpp
AuthToken.cpp
Cluster.cpp
Common.cpp