Skip to content

Commit 2a57834

Browse files
add test to check for duplicate folder creation
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
1 parent 82061a4 commit 2a57834

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

library/src/androidTest/java/com/owncloud/android/CreateFolderRemoteOperationIT.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
*/
88
package com.owncloud.android;
99

10+
import static com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode.FOLDER_ALREADY_EXISTS;
1011
import static org.junit.Assert.assertEquals;
12+
import static org.junit.Assert.assertFalse;
1113
import static org.junit.Assert.assertTrue;
1214

1315
import com.nextcloud.test.RandomStringGenerator;
@@ -66,6 +68,23 @@ public void testCreateFolder() {
6668
assertTrue(result.isSuccess());
6769
}
6870

71+
/**
72+
* Test duplicate Folder
73+
*/
74+
@Test
75+
public void testCreateDuplicateFolder() {
76+
String remotePath = mFullPath2FolderBase + "duplicateFolder";
77+
mCreatedFolderPaths.add(remotePath);
78+
RemoteOperationResult<String> result = new CreateFolderRemoteOperation(remotePath, true).execute(client);
79+
assertTrue(result.isSuccess());
80+
81+
// Create folder again
82+
mCreatedFolderPaths.add(remotePath);
83+
result = new CreateFolderRemoteOperation(remotePath, true).execute(client);
84+
assertFalse(result.isSuccess());
85+
assertEquals(FOLDER_ALREADY_EXISTS, result.getCode());
86+
}
87+
6988
@Test
7089
public void testFileID() {
7190
String remotePath = mFullPath2FolderBase + "/" + RandomStringGenerator.make(TAG_LENGTH);

0 commit comments

Comments
 (0)