Merge pull request #6560 from nextcloud/fixLargeTest

make sure to delete all uploads
This commit is contained in:
Andy Scherzinger 2020-07-28 12:05:18 +02:00 committed by GitHub
commit c981833bc1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -28,9 +28,9 @@ import java.io.File;
import java.util.ArrayList;
import java.util.Random;
import androidx.test.InstrumentationRegistry;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@ -49,7 +49,7 @@ public class UploadStorageManagerTest extends AbstractIT {
@Before
public void setUp() {
Context instrumentationCtx = InstrumentationRegistry.getTargetContext();
Context instrumentationCtx = ApplicationProvider.getApplicationContext();
ContentResolver contentResolver = instrumentationCtx.getContentResolver();
uploadsStorageManager = new UploadsStorageManager(currentAccountProvider, contentResolver);
@ -94,6 +94,7 @@ public class UploadStorageManagerTest extends AbstractIT {
int size = 3000;
ArrayList<OCUpload> uploads = new ArrayList<>();
deleteAllUploads();
assertEquals(0, uploadsStorageManager.getAllStoredUploads().length);
for (int i = 0; i < size; i++) {
@ -156,8 +157,14 @@ public class UploadStorageManagerTest extends AbstractIT {
}
private OCUpload createUpload(Account account) {
OCUpload upload = new OCUpload(File.separator + "very long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long LocalPath",
OCFile.PATH_SEPARATOR + "very long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long RemotePath",
OCUpload upload = new OCUpload(File.separator + "very long long long long long long long long long long long " +
"long long long long long long long long long long long long long long " +
"long long long long long long long long long long long long long long " +
"long long long long long long long LocalPath",
OCFile.PATH_SEPARATOR + "very long long long long long long long long long " +
"long long long long long long long long long long long long long long " +
"long long long long long long long long long long long long long long " +
"long long long long long long long long long long long long RemotePath",
account.name);
upload.setFileSize(new Random().nextInt(20000) * 10000);
@ -175,12 +182,18 @@ public class UploadStorageManagerTest extends AbstractIT {
return upload;
}
@After
public void tearDown() {
private void deleteAllUploads() {
for (Account account : getAllAccounts()) {
uploadsStorageManager.removeAccountUploads(account);
}
assertEquals(0, uploadsStorageManager.getAllStoredUploads().length);
}
@After
public void tearDown() {
deleteAllUploads();
AccountManager platformAccountManager = AccountManager.get(targetContext);
platformAccountManager.removeAccountExplicitly(account2);
}