Made some small optims when checking if files are removed
This commit is contained in:
@@ -208,4 +208,29 @@ namespace lms::db::tests
|
||||
ASSERT_TRUE(visited);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(DatabaseFixture, ArtistInfo_findAbsoluteFilePath)
|
||||
{
|
||||
ScopedArtistInfo artistInfo{ session };
|
||||
|
||||
const std::filesystem::path absoluteFilePath{ "/path/to/artist.nfo" };
|
||||
{
|
||||
auto transaction{ session.createWriteTransaction() };
|
||||
artistInfo.get().modify()->setAbsoluteFilePath(absoluteFilePath);
|
||||
}
|
||||
|
||||
{
|
||||
auto transaction{ session.createReadTransaction() };
|
||||
|
||||
ArtistInfoId lastRetrievedId;
|
||||
|
||||
std::filesystem::path retrievedFilePath;
|
||||
ArtistInfo::findAbsoluteFilePath(session, lastRetrievedId, 1, [&](ArtistInfoId artistInfoId, const std::filesystem::path& filePath) {
|
||||
EXPECT_EQ(artistInfoId, artistInfo.getId());
|
||||
retrievedFilePath = filePath;
|
||||
});
|
||||
|
||||
EXPECT_EQ(retrievedFilePath, absoluteFilePath);
|
||||
}
|
||||
}
|
||||
} // namespace lms::db::tests
|
||||
@@ -98,4 +98,28 @@ namespace lms::db::tests
|
||||
EXPECT_EQ(results.front()->getId(), image.getId());
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(DatabaseFixture, Image_findAbsoluteFilePath)
|
||||
{
|
||||
ScopedImage image{ session, "/path/to/image" };
|
||||
|
||||
const std::filesystem::path absoluteFilePath{ "/path/to/image" };
|
||||
{
|
||||
auto transaction{ session.createWriteTransaction() };
|
||||
image.get().modify()->setAbsoluteFilePath(absoluteFilePath);
|
||||
}
|
||||
|
||||
{
|
||||
auto transaction{ session.createReadTransaction() };
|
||||
ImageId lastRetrievedImageId;
|
||||
std::filesystem::path retrievedPath;
|
||||
Image::findAbsoluteFilePath(session, lastRetrievedImageId, 1, [&](ImageId id, const std::filesystem::path& path) {
|
||||
EXPECT_EQ(id, image.getId());
|
||||
retrievedPath = path;
|
||||
});
|
||||
|
||||
EXPECT_EQ(retrievedPath, absoluteFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace lms::db::tests
|
||||
@@ -85,6 +85,24 @@ namespace lms::db::tests
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(DatabaseFixture, PlayListFile_findAbsoluteFilePath)
|
||||
{
|
||||
ScopedPlayListFile playlist{ session, "/tmp/foo.m3u" };
|
||||
|
||||
{
|
||||
auto transaction{ session.createReadTransaction() };
|
||||
|
||||
PlayListFileId lastRetrievedId;
|
||||
std::filesystem::path retrievedFilePath;
|
||||
PlayListFile::findAbsoluteFilePath(session, lastRetrievedId, 1, [&](PlayListFileId playListFileId, const std::filesystem::path& filePath) {
|
||||
EXPECT_EQ(playListFileId, playlist.getId());
|
||||
retrievedFilePath = filePath;
|
||||
});
|
||||
|
||||
EXPECT_EQ(retrievedFilePath, "/tmp/foo.m3u");
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(DatabaseFixture, PlayListFile_deleteTrackList)
|
||||
{
|
||||
{
|
||||
|
||||
@@ -151,6 +151,30 @@ namespace lms::db::tests
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(DatabaseFixture, Track_findAbsoluteFilePath)
|
||||
{
|
||||
ScopedTrack track{ session };
|
||||
const std::filesystem::path absoluteFilePath{ "/path/to/track.mp3" };
|
||||
{
|
||||
auto transaction{ session.createWriteTransaction() };
|
||||
track.get().modify()->setAbsoluteFilePath(absoluteFilePath);
|
||||
}
|
||||
|
||||
{
|
||||
auto transaction{ session.createReadTransaction() };
|
||||
|
||||
TrackId lastRetrievedTrackId;
|
||||
std::vector<std::pair<TrackId, std::filesystem::path>> visitedTracks;
|
||||
Track::findAbsoluteFilePath(session, lastRetrievedTrackId, 10, [&](TrackId trackId, const std::filesystem::path& filePath) {
|
||||
visitedTracks.emplace_back(trackId, filePath);
|
||||
});
|
||||
ASSERT_EQ(visitedTracks.size(), 1);
|
||||
EXPECT_EQ(visitedTracks[0].first, track.getId());
|
||||
EXPECT_EQ(visitedTracks[0].second, absoluteFilePath);
|
||||
EXPECT_EQ(lastRetrievedTrackId, track.getId());
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(DatabaseFixture, Track_MediaLibrary)
|
||||
{
|
||||
ScopedTrack track{ session };
|
||||
|
||||
@@ -26,6 +26,32 @@ namespace lms::db::tests
|
||||
{
|
||||
using ScopedTrackLyrics = ScopedEntity<db::TrackLyrics>;
|
||||
|
||||
TEST_F(DatabaseFixture, TrackLyrics_findAbsoluteFilePath)
|
||||
{
|
||||
ScopedTrack track{ session };
|
||||
ScopedTrackLyrics lyrics{ session };
|
||||
|
||||
{
|
||||
auto transaction{ session.createWriteTransaction() };
|
||||
|
||||
TrackLyrics::pointer dbLyrics{ lyrics.get() };
|
||||
|
||||
dbLyrics.modify()->setAbsoluteFilePath("/tmp/test.lrc");
|
||||
dbLyrics.modify()->setTrack(track.get());
|
||||
}
|
||||
{
|
||||
auto transaction{ session.createReadTransaction() };
|
||||
|
||||
TrackLyricsId lastRetrievedId;
|
||||
std::filesystem::path retrievedFilePath;
|
||||
TrackLyrics::findAbsoluteFilePath(session, lastRetrievedId, 1, [&](TrackLyricsId trackLyricsId, const std::filesystem::path& absoluteFilePath) {
|
||||
EXPECT_EQ(trackLyricsId, lyrics.getId());
|
||||
retrievedFilePath = absoluteFilePath;
|
||||
});
|
||||
EXPECT_EQ(retrievedFilePath, "/tmp/test.lrc");
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(DatabaseFixture, TrackLyrics_synchronized)
|
||||
{
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
Reference in New Issue
Block a user