Added a scan step to scan artist images, ref #435

This commit is contained in:
emeric
2024-06-29 16:04:16 +02:00
parent 504c0824fb
commit 71dc99ad46
37 changed files with 983 additions and 348 deletions
+1
View File
@@ -4,6 +4,7 @@ add_executable(test-database
Cluster.cpp
Common.cpp
DatabaseTest.cpp
Image.cpp
Listen.cpp
Migration.cpp
Release.cpp
+2
View File
@@ -22,6 +22,7 @@
#include "database/Artist.hpp"
#include "database/Cluster.hpp"
#include "database/Db.hpp"
#include "database/Image.hpp"
#include "database/Listen.hpp"
#include "database/MediaLibrary.hpp"
#include "database/Release.hpp"
@@ -80,6 +81,7 @@ namespace lms::db::tests
EXPECT_EQ(Cluster::getCount(session), 0);
EXPECT_EQ(ClusterType::getCount(session), 0);
EXPECT_EQ(Listen::getCount(session), 0);
EXPECT_EQ(Image::getCount(session), 0);
EXPECT_EQ(MediaLibrary::getCount(session), 0);
EXPECT_EQ(Release::getCount(session), 0);
EXPECT_EQ(StarredArtist::getCount(session), 0);
+66
View File
@@ -0,0 +1,66 @@
/*
* Copyright (C) 2024 Emeric Poupon
*
* This file is part of 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/Image.hpp"
namespace lms::db::tests
{
using ScopedImage = ScopedEntity<db::Image>;
TEST_F(DatabaseFixture, Image)
{
ScopedImage image{ session, "/path/to/image" };
{
auto transaction{ session.createReadTransaction() };
EXPECT_EQ(Image::getCount(session), 1);
Image::pointer img{ Image::find(session, image.getId()) };
ASSERT_NE(img, Image::pointer{});
EXPECT_EQ(img->getPath(), "/path/to/image");
EXPECT_EQ(img->getWidth(), 0);
EXPECT_EQ(img->getHeight(), 0);
EXPECT_EQ(img->getFileSize(), 0);
}
{
auto transaction{ session.createWriteTransaction() };
Image::pointer img{ Image::find(session, image.getId()) };
ASSERT_NE(img, Image::pointer{});
img.modify()->setPath("/path/to/another/image");
img.modify()->setWidth(640);
img.modify()->setHeight(480);
img.modify()->setFileSize(1024 * 1024);
}
{
auto transaction{ session.createReadTransaction() };
Image::pointer img{ Image::find(session, image.getId()) };
ASSERT_NE(img, Image::pointer{});
EXPECT_EQ(img->getPath(), "/path/to/another/image");
EXPECT_EQ(img->getWidth(), 640);
EXPECT_EQ(img->getHeight(), 480);
EXPECT_EQ(img->getFileSize(), 1024 * 1024);
}
}
} // namespace lms::db::tests