Updated tests to work with flipped repo priorities.

This commit is contained in:
Peter Serwylo 2017-04-05 09:09:51 +10:00
parent c6efdbb20c
commit 1aea1c9302
2 changed files with 32 additions and 17 deletions

View File

@ -44,8 +44,7 @@ public class CategoryProviderTest extends FDroidProviderTest {
insertAppWithCategory("com.dog.rock.apple", "Dog-Rock-Apple", "Animal,Mineral,Vegetable", mainRepo);
insertAppWithCategory("com.banana.apple", "Banana", "Vegetable,Vegetable", mainRepo);
List<String> categories = CategoryProvider.Helper.categories(context);
String[] expected = new String[] {
String[] expectedFDroid = new String[] {
context.getResources().getString(R.string.category_Whats_New),
context.getResources().getString(R.string.category_Recently_Updated),
context.getResources().getString(R.string.category_All),
@ -56,13 +55,8 @@ public class CategoryProviderTest extends FDroidProviderTest {
"Vegetable",
"Writing",
};
assertContainsOnly(categories, expected);
insertAppWithCategory("info.guardianproject.notepadbot", "NoteCipher", "Office,GuardianProject", gpRepo);
assertContainsOnly(CategoryProvider.Helper.categories(context), expected);
RepoProvider.Helper.purgeApps(context, new MockRepo(mainRepo));
String[] expectedGp = new String[] {
String[] expectedGP = new String[] {
context.getResources().getString(R.string.category_Whats_New),
context.getResources().getString(R.string.category_Recently_Updated),
context.getResources().getString(R.string.category_All),
@ -70,8 +64,29 @@ public class CategoryProviderTest extends FDroidProviderTest {
"GuardianProject",
"Office",
};
// We overwrite "Security" + "Writing" with "GuardianProject" + "Office"
String[] expectedBoth = new String[] {
context.getResources().getString(R.string.category_Whats_New),
context.getResources().getString(R.string.category_Recently_Updated),
context.getResources().getString(R.string.category_All),
"Animal",
"Mineral",
"Vegetable",
"GuardianProject",
"Office",
};
assertContainsOnly(CategoryProvider.Helper.categories(context), expectedFDroid);
insertAppWithCategory("info.guardianproject.notepadbot", "NoteCipher", "Office,GuardianProject", gpRepo);
assertContainsOnly(CategoryProvider.Helper.categories(context), expectedBoth);
RepoProvider.Helper.purgeApps(context, new MockRepo(mainRepo));
List<String> categoriesAfterPurge = CategoryProvider.Helper.categories(context);
assertContainsOnly(categoriesAfterPurge, expectedGp);
assertContainsOnly(categoriesAfterPurge, expectedGP);
}
@Test

View File

@ -95,15 +95,15 @@ public class ProperMultiRepoUpdaterTest extends MultiRepoUpdaterTest {
@Test
public void metadataWithRepoPriority() throws RepoUpdater.UpdateException {
updateConflicting();
updateMain();
updateArchive();
updateConflicting();
Repo conflictingRepo = RepoProvider.Helper.findByAddress(context, REPO_CONFLICTING_URI);
Repo mainRepo = RepoProvider.Helper.findByAddress(context, REPO_MAIN_URI);
assertEquals(1, conflictingRepo.priority);
assertEquals(2, RepoProvider.Helper.findByAddress(context, REPO_MAIN_URI).priority);
assertEquals(3, RepoProvider.Helper.findByAddress(context, REPO_ARCHIVE_URI).priority);
assertEquals(1, mainRepo.priority);
assertEquals(2, RepoProvider.Helper.findByAddress(context, REPO_ARCHIVE_URI).priority);
assertEquals(3, RepoProvider.Helper.findByAddress(context, REPO_CONFLICTING_URI).priority);
assertMainRepo();
assertMainArchiveRepoMetadata();
@ -114,9 +114,9 @@ public class ProperMultiRepoUpdaterTest extends MultiRepoUpdaterTest {
// Make the conflicting repo less important than the main repo.
ContentValues values = new ContentValues(1);
values.put(Cols.PRIORITY, 5);
RepoProvider.Helper.update(context, conflictingRepo, values);
Repo updatedConflictingRepo = RepoProvider.Helper.findByAddress(context, REPO_CONFLICTING_URI);
assertEquals(5, updatedConflictingRepo.priority);
RepoProvider.Helper.update(context, mainRepo, values);
Repo updatedMainRepo = RepoProvider.Helper.findByAddress(context, REPO_MAIN_URI);
assertEquals(5, updatedMainRepo.priority);
assertRepoTakesPriority("Normal");
}