summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorUwe Klotz <uklotz@mixxx.org>2020-11-15 12:23:12 +0100
committerUwe Klotz <uklotz@mixxx.org>2020-11-15 13:56:51 +0100
commitdbeaf5b5936dff8a62cfac4fb90ad4486ba4b127 (patch)
tree10a3ad8fd6c912cbc8bbb00aefba695b68b9eb85 /src/test
parent3e1f1c44db104ccc806779802c00eb22cc35c74b (diff)
Fix DirectoryDAOTest::relocateDirectory() on macOS
Diffstat (limited to 'src/test')
-rw-r--r--src/test/directorydaotest.cpp33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/test/directorydaotest.cpp b/src/test/directorydaotest.cpp
index faad6154bd..a38d49e3a2 100644
--- a/src/test/directorydaotest.cpp
+++ b/src/test/directorydaotest.cpp
@@ -130,16 +130,25 @@ TEST_F(DirectoryDAOTest, getDirTest) {
EXPECT_QSTRING_EQ(testdir2, dirs.at(1));
}
-TEST_F(DirectoryDAOTest, relocateDirTest) {
- DirectoryDAO& directoryDao = internalCollection()->getDirectoryDAO();
+TEST_F(DirectoryDAOTest, relocateDirectory) {
+ // Test with 2 independent root directories for relocation
+ const QTemporaryDir tempDir1;
+ ASSERT_TRUE(tempDir1.isValid());
+ const QTemporaryDir tempDir2;
+ ASSERT_TRUE(tempDir2.isValid());
- // use a temp dir so that we always use a real existing system path
- QString testdir(QDir::tempPath() + "/TestDir");
- QString test2(QDir::tempPath() + "/TestDir2");
- QString testnew(QDir::tempPath() + "/TestDirNew");
+ //create temp dirs
+ QString testdir(tempDir1.path() + "/TestDir");
+ ASSERT_TRUE(QDir(tempDir1.path()).mkpath(testdir));
+ QString test2(tempDir2.path() + "/TestDir2");
+ ASSERT_TRUE(QDir(tempDir2.path()).mkpath(test2));
+ QString testnew(tempDir2.path() + "/TestDirNew");
+ ASSERT_TRUE(QDir(tempDir2.path()).mkpath(testnew));
+
+ const DirectoryDAO& dao = internalCollection()->getDirectoryDAO();
- directoryDao.addDirectory(testdir);
- directoryDao.addDirectory(test2);
+ ASSERT_EQ(ALL_FINE, dao.addDirectory(testdir));
+ ASSERT_EQ(ALL_FINE, dao.addDirectory(test2));
// ok now lets create some tracks here
ASSERT_TRUE(internalCollection()
@@ -168,10 +177,10 @@ TEST_F(DirectoryDAOTest, relocateDirTest) {
.isValid());
QList<RelocatedTrack> relocatedTracks =
- directoryDao.relocateDirectory(testdir, testnew);
+ dao.relocateDirectory(testdir, testnew);
EXPECT_EQ(2, relocatedTracks.size());
- QStringList dirs = directoryDao.getDirs();
- EXPECT_EQ(2, dirs.size());
- EXPECT_THAT(dirs, UnorderedElementsAre(test2, testnew));
+ const QStringList allDirs = dao.getDirs();
+ EXPECT_EQ(2, allDirs.size());
+ EXPECT_THAT(allDirs, UnorderedElementsAre(test2, testnew));
}