Skip to content

Commit 870ec84

Browse files
Tests for file conflict name generator specific for offlineOperations
Signed-off-by: daniele-verducci <daniele.verducci@nextcloud.com>
1 parent 0c93a95 commit 870ec84

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

app/src/androidTest/java/com/owncloud/android/datamodel/FileDataStorageManagerIT.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
package com.owncloud.android.datamodel;
99

1010
import android.content.ContentValues;
11+
import android.util.Pair;
1112

13+
import com.nextcloud.utils.extensions.FileDataStorageManagerExtensionsKt;
1214
import com.owncloud.android.AbstractOnServerIT;
1315
import com.owncloud.android.db.ProviderMeta;
1416
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
@@ -353,4 +355,27 @@ public void testOCCapability() {
353355
assertEquals(capability.getUserStatus(), newCapability.getUserStatus());
354356
}
355357

358+
@Test
359+
public void testGenerateFileNameForConflictResolution() {
360+
Pair<String, String>[] names = new Pair[]{
361+
// Files
362+
new Pair<String, String>("hello", "hello (1)"),
363+
new Pair<String, String>("hello.txt", "hello (1).txt"),
364+
new Pair<String, String>("hello (1).txt", "hello (2).txt"),
365+
new Pair<String, String>("hello (18y5).txt", "hello (18y5) (1).txt"),
366+
new Pair<String, String>("hello (hey)", "hello (hey) (1)"),
367+
new Pair<String, String>("hello (hey).txt", "hello (hey) (1).txt"),
368+
// Folders
369+
new Pair<String, String>("hello/", "hello (1)/"),
370+
new Pair<String, String>("hello (1)/", "hello (2)/"),
371+
new Pair<String, String>("hello.hello/", "hello.hello (1)/"),
372+
new Pair<String, String>("hello.hello (y)/", "hello.hello (y) (1)/"),
373+
};
374+
375+
for (Pair<String, String> name : names) {
376+
String gen = FileDataStorageManagerExtensionsKt.generateFileNameForConflictResolution(name.first);
377+
assertEquals(gen, name.second);
378+
}
379+
}
380+
356381
}

0 commit comments

Comments
 (0)