Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHannah von Reth <hannah.vonreth@owncloud.com>2020-03-20 13:17:48 +0300
committerHannah von Reth <vonreth@kde.org>2020-03-25 13:40:43 +0300
commit3504ae8fc5e0a9fe0f2dc79d03a80ba83745cf3f (patch)
tree6a7183216fbdf64b6b84b5b49df28b5528a8ad49 /test
parent4da684b95ca9b1f80b72d33d57bf52d9802ec3d7 (diff)
Test: Add test for vfs failed move crash
Diffstat (limited to 'test')
-rw-r--r--test/syncenginetestutils.h4
-rw-r--r--test/testsyncmove.cpp57
2 files changed, 61 insertions, 0 deletions
diff --git a/test/syncenginetestutils.h b/test/syncenginetestutils.h
index eb757edd5..21cbf134c 100644
--- a/test/syncenginetestutils.h
+++ b/test/syncenginetestutils.h
@@ -307,6 +307,10 @@ public:
&& children == other.children;
}
+ bool operator!=(const FileInfo &other) const {
+ return !operator==(other);
+ }
+
QString path() const {
return (parentPath.isEmpty() ? QString() : (parentPath + '/')) + name;
}
diff --git a/test/testsyncmove.cpp b/test/testsyncmove.cpp
index 9a503be29..984b853ca 100644
--- a/test/testsyncmove.cpp
+++ b/test/testsyncmove.cpp
@@ -857,6 +857,63 @@ private slots:
QVERIFY(fakeFolder.syncOnce());
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
}
+
+ void testMovedWithError_data()
+ {
+ QTest::addColumn<Vfs::Mode>("vfsMode");
+
+ QTest::newRow("Vfs::Off") << Vfs::Off;
+ QTest::newRow("Vfs::WithSuffix") << Vfs::WithSuffix;
+#ifdef Q_OS_WIN32
+ QTest::newRow("Vfs::WindowsCfApi") << Vfs::WindowsCfApi;
+#endif
+ }
+
+ void testMovedWithError()
+ {
+ QFETCH(Vfs::Mode, vfsMode);
+ const auto getName = [vfsMode] (const QString &s)
+ {
+ if (vfsMode == Vfs::WithSuffix)
+ {
+ return QStringLiteral("%1" APPLICATION_DOTVIRTUALFILE_SUFFIX).arg(s);
+ }
+ return s;
+ };
+ const QByteArray testPath = "folder/folderA/file.txt";
+ FakeFolder fakeFolder{ FileInfo{ QString(), { FileInfo{ QStringLiteral("folder"), { FileInfo{ QStringLiteral("folderA"), { { QStringLiteral("file.txt"), 400 } } }, QStringLiteral("folderB") } } } } };
+
+ QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
+
+ if (vfsMode != Vfs::Off)
+ {
+ auto vfs = QSharedPointer<Vfs>(createVfsFromPlugin(Vfs::WithSuffix).release());
+ QVERIFY(vfs);
+ fakeFolder.switchToVfs(vfs);
+ fakeFolder.syncJournal().internalPinStates().setForPath("", PinState::OnlineOnly);
+
+ // make files virtual
+ fakeFolder.syncOnce();
+ }
+
+ fakeFolder.serverErrorPaths().append(testPath, 403);
+ fakeFolder.localModifier().rename(getName(testPath), getName("folder/folderB/file.txt"));
+
+ // sync1 file gets detected as error, instruction is still NEW_FILE
+ fakeFolder.syncOnce();
+
+ // sync2 file is in error state, checkErrorBlacklisting sets instruction to IGNORED
+ fakeFolder.syncOnce();
+
+ if (vfsMode != Vfs::Off)
+ {
+ fakeFolder.syncJournal().internalPinStates().setForPath("", PinState::AlwaysLocal);
+ fakeFolder.syncOnce();
+ }
+ // the sync must have failed as we have a file in the error state
+ QVERIFY(fakeFolder.currentLocalState() != fakeFolder.currentRemoteState());
+ }
+
};
QTEST_GUILESS_MAIN(TestSyncMove)