Add test for correct handling of live photo mov deletion
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Wed, 30 Oct 2024 04:17:27 +0000 (12:17 +0800)
committerMatthieu Gallien <matthieu.gallien@nextcloud.com>
Wed, 20 Nov 2024 13:39:51 +0000 (14:39 +0100)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
test/testlocaldiscovery.cpp

index 687b46d79572d6ed5495f32aa0f88536897b858a..bb6bcdc01f374cfdf850030d0e503e12914591e2 100644 (file)
@@ -333,6 +333,41 @@ private slots:
         QVERIFY(!fakeFolder.currentRemoteState().find("C/filename.ext"));
     }
 
+    void testRedownloadDeletedLivePhotoMov()
+    {
+        FakeFolder fakeFolder{FileInfo{}};
+        QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
+        const auto livePhotoImg = QStringLiteral("IMG_0001.heic");
+        const auto livePhotoMov = QStringLiteral("IMG_0001.mov");
+        fakeFolder.localModifier().insert(livePhotoImg);
+        fakeFolder.localModifier().insert(livePhotoMov);
+
+        ItemCompletedSpy completeSpy(fakeFolder);
+        QVERIFY(fakeFolder.syncOnce());
+
+        QCOMPARE(completeSpy.findItem(livePhotoImg)->_status, SyncFileItem::Status::Success);
+        QCOMPARE(completeSpy.findItem(livePhotoMov)->_status, SyncFileItem::Status::Success);
+
+        fakeFolder.remoteModifier().setIsLivePhoto(livePhotoImg, true);
+        fakeFolder.remoteModifier().setIsLivePhoto(livePhotoMov, true);
+        QVERIFY(fakeFolder.syncOnce());
+
+        SyncJournalFileRecord imgRecord;
+        QVERIFY(fakeFolder.syncJournal().getFileRecord(livePhotoImg, &imgRecord));
+        QVERIFY(imgRecord._isLivePhoto);
+
+        SyncJournalFileRecord movRecord;
+        QVERIFY(fakeFolder.syncJournal().getFileRecord(livePhotoMov, &movRecord));
+        QVERIFY(movRecord._isLivePhoto);
+
+        completeSpy.clear();
+        fakeFolder.localModifier().remove(livePhotoMov);
+        QVERIFY(fakeFolder.syncOnce());
+        QCOMPARE(completeSpy.findItem(livePhotoMov)->_status, SyncFileItem::Status::Success);
+        QCOMPARE(completeSpy.findItem(livePhotoMov)->_instruction, CSYNC_INSTRUCTION_SYNC);
+        QCOMPARE(completeSpy.findItem(livePhotoMov)->_direction, SyncFileItem::Direction::Down);
+    }
+
     void testCreateFileWithTrailingSpaces_localAndRemoteTrimmedDoNotExist_renameAndUploadFile()
     {
         FakeFolder fakeFolder{FileInfo{}};