From 2a57834789fb1805e0b88da20fcb56bbee473b96 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Mon, 8 Apr 2024 18:10:43 +0200 Subject: [PATCH] add test to check for duplicate folder creation Signed-off-by: tobiasKaminsky --- .../CreateFolderRemoteOperationIT.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/library/src/androidTest/java/com/owncloud/android/CreateFolderRemoteOperationIT.java b/library/src/androidTest/java/com/owncloud/android/CreateFolderRemoteOperationIT.java index a8ed202c8..4f7b02dfc 100644 --- a/library/src/androidTest/java/com/owncloud/android/CreateFolderRemoteOperationIT.java +++ b/library/src/androidTest/java/com/owncloud/android/CreateFolderRemoteOperationIT.java @@ -7,7 +7,9 @@ */ package com.owncloud.android; +import static com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode.FOLDER_ALREADY_EXISTS; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import com.nextcloud.test.RandomStringGenerator; @@ -66,6 +68,23 @@ public void testCreateFolder() { assertTrue(result.isSuccess()); } + /** + * Test duplicate Folder + */ + @Test + public void testCreateDuplicateFolder() { + String remotePath = mFullPath2FolderBase + "duplicateFolder"; + mCreatedFolderPaths.add(remotePath); + RemoteOperationResult result = new CreateFolderRemoteOperation(remotePath, true).execute(client); + assertTrue(result.isSuccess()); + + // Create folder again + mCreatedFolderPaths.add(remotePath); + result = new CreateFolderRemoteOperation(remotePath, true).execute(client); + assertFalse(result.isSuccess()); + assertEquals(FOLDER_ALREADY_EXISTS, result.getCode()); + } + @Test public void testFileID() { String remotePath = mFullPath2FolderBase + "/" + RandomStringGenerator.make(TAG_LENGTH);