瀏覽代碼

Merge pull request #3682 from nextcloud/deleteFilesAfterTest

Enhance integration tests
Andy Scherzinger 6 年之前
父節點
當前提交
2e4a43eecd

+ 8 - 1
src/androidTest/java/com/owncloud/android/FileIT.java

@@ -2,12 +2,13 @@ package com.owncloud.android;
 
 import com.owncloud.android.lib.common.operations.RemoteOperationResult;
 import com.owncloud.android.operations.CreateFolderOperation;
+import com.owncloud.android.operations.RemoveFileOperation;
 import com.owncloud.android.operations.common.SyncOperation;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
-import androidx.test.runner.AndroidJUnit4;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
 
 import static junit.framework.TestCase.assertTrue;
 import static org.junit.Assert.assertNull;
@@ -32,6 +33,9 @@ public class FileIT extends AbstractIT {
 
         // folder exists
         assertTrue(getStorageManager().getFileByPath(path).isFolder());
+
+        // cleanup
+        new RemoveFileOperation(path, false, account, false, context).execute(client, getStorageManager());
     }
 
     @Test
@@ -46,5 +50,8 @@ public class FileIT extends AbstractIT {
 
         // folder exists
         assertTrue(getStorageManager().getFileByPath(path).isFolder());
+
+        // cleanup
+        new RemoveFileOperation("/testFolder/", false, account, false, context).execute(client, getStorageManager());
     }
 }

+ 14 - 1
src/androidTest/java/com/owncloud/android/UploadIT.java

@@ -3,13 +3,14 @@ package com.owncloud.android;
 import com.owncloud.android.db.OCUpload;
 import com.owncloud.android.files.services.FileUploader;
 import com.owncloud.android.lib.common.operations.RemoteOperationResult;
+import com.owncloud.android.operations.RemoveFileOperation;
 import com.owncloud.android.operations.UploadFileOperation;
 import com.owncloud.android.utils.FileStorageUtils;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
-import androidx.test.runner.AndroidJUnit4;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
 
 import static junit.framework.TestCase.assertTrue;
 
@@ -28,6 +29,9 @@ public class UploadIT extends AbstractIT {
         RemoteOperationResult result = testUpload(ocUpload);
 
         assertTrue(result.isSuccess());
+
+        // cleanup
+        new RemoveFileOperation("/testUpload/", false, account, false, context).execute(client, getStorageManager());
     }
 
     @Test
@@ -38,6 +42,9 @@ public class UploadIT extends AbstractIT {
         RemoteOperationResult result = testUpload(ocUpload);
 
         assertTrue(result.isSuccess());
+
+        // cleanup
+        new RemoveFileOperation("/testUpload/", false, account, false, context).execute(client, getStorageManager());
     }
 
     @Test
@@ -48,6 +55,9 @@ public class UploadIT extends AbstractIT {
         RemoteOperationResult result = testUpload(ocUpload);
 
         assertTrue(result.isSuccess());
+
+        // cleanup
+        new RemoveFileOperation("/testUpload/", false, account, false, context).execute(client, getStorageManager());
     }
 
     public RemoteOperationResult testUpload(OCUpload ocUpload) {
@@ -92,5 +102,8 @@ public class UploadIT extends AbstractIT {
 
         RemoteOperationResult result = newUpload.execute(client, getStorageManager());
         assertTrue(result.isSuccess());
+
+        // cleanup
+        new RemoveFileOperation("/testUpload/", false, account, false, context).execute(client, getStorageManager());
     }
 }