diff --git a/libs/database/src/test/java/org/fdroid/repo/RepoAdderTest.kt b/libs/database/src/test/java/org/fdroid/repo/RepoAdderTest.kt index 1a678a649..05e1148bf 100644 --- a/libs/database/src/test/java/org/fdroid/repo/RepoAdderTest.kt +++ b/libs/database/src/test/java/org/fdroid/repo/RepoAdderTest.kt @@ -21,6 +21,7 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.delay import kotlinx.coroutines.launch import kotlinx.coroutines.test.runTest +import kotlinx.serialization.builtins.serializer import org.fdroid.LocaleChooser.getBestLocale import org.fdroid.database.FDroidDatabase import org.fdroid.database.Mirror @@ -44,6 +45,9 @@ import org.fdroid.repo.AddRepoError.ErrorType.INVALID_FINGERPRINT import org.fdroid.repo.AddRepoError.ErrorType.INVALID_INDEX import org.fdroid.repo.AddRepoError.ErrorType.IO_ERROR import org.fdroid.repo.AddRepoError.ErrorType.UNKNOWN_SOURCES_DISALLOWED +import org.fdroid.repo.FetchResult.IsNewMirror +import org.fdroid.repo.FetchResult.IsNewRepoAndNewMirror +import org.fdroid.repo.FetchResult.IsNewRepository import org.fdroid.test.TestDataMinV2 import org.fdroid.test.TestUtils.decodeHex import org.fdroid.test.TestUtils.getRandomString @@ -135,7 +139,7 @@ internal class RepoAdderTest { @Test fun testAddingMinRepo() = runTest { - val url = "https://example.org/repo/" + val url = "https://min-v1.org/repo/" val urlTrimmed = url.trimEnd('/') val repoName = TestDataMinV2.repo.name.getBestLocale(localeList) @@ -144,7 +148,7 @@ internal class RepoAdderTest { // repo not in DB every { repoDao.getRepository(any()) } returns null - expectMinRepoPreview(repoName, FetchResult.IsNewRepoAndNewMirror) { + expectMinRepoPreview(repoName, IsNewRepository) { repoAdder.fetchRepository(url = url, proxy = null) } @@ -164,10 +168,10 @@ internal class RepoAdderTest { }) } returns 42L every { repoDao.getRepository(42L) } returns newRepo - every { repoDao.updateUserMirrors(42L, listOf(urlTrimmed)) } just Runs repoAdder.addRepoState.test { - assertIs(awaitItem()) // still Fetching from last call + val fetching: Fetching = awaitItem() as Fetching // still Fetching from last call + assertIs(fetching.fetchResult) repoAdder.addFetchedRepository() @@ -177,10 +181,6 @@ internal class RepoAdderTest { assertIs(addedState) assertEquals(newRepo, addedState.repo) } - - verify { - repoDao.updateUserMirrors(42L, listOf(urlTrimmed)) - } } @Test @@ -206,7 +206,7 @@ internal class RepoAdderTest { ) every { repoDao.getRepository(any()) } returns existingRepo - expectMinRepoPreview(repoName, FetchResult.IsNewMirror(42L)) { + expectMinRepoPreview(repoName, IsNewMirror(42L)) { repoAdder.fetchRepository(url = url, proxy = null) } @@ -218,7 +218,9 @@ internal class RepoAdderTest { every { repoDao.updateUserMirrors(42L, listOf(url.trimEnd('/'))) } just Runs repoAdder.addRepoState.test { - assertIs(awaitItem()) // still Fetching from last call + val fetching: Fetching = awaitItem() as Fetching // still Fetching from last call + assertIs(fetching.fetchResult) + assertEquals(existingRepo.repoId, fetching.fetchResult.existingRepoId) repoAdder.addFetchedRepository() @@ -699,7 +701,7 @@ internal class RepoAdderTest { } val addRepoState = repoAdder.addRepoState.value assertIs(addRepoState) - assertIs(addRepoState.fetchResult) + assertIs(addRepoState.fetchResult) assertEquals(63, addRepoState.apps.size) } diff --git a/libs/sharedTest/src/main/assets/diff-empty-min/23.json b/libs/sharedTest/src/main/assets/diff-empty-min/23.json index 43973741f..4f14bedc9 100644 --- a/libs/sharedTest/src/main/assets/diff-empty-min/23.json +++ b/libs/sharedTest/src/main/assets/diff-empty-min/23.json @@ -10,7 +10,7 @@ "size": 0 } }, - "address": "https://min-v1.org", + "address": "https://min-v1.org/repo", "description": { "en-US": "This is a repo with minimal data." }, diff --git a/libs/sharedTest/src/main/assets/index-min-reordered-v2.json b/libs/sharedTest/src/main/assets/index-min-reordered-v2.json index 858d00bed..3387f2942 100644 --- a/libs/sharedTest/src/main/assets/index-min-reordered-v2.json +++ b/libs/sharedTest/src/main/assets/index-min-reordered-v2.json @@ -33,7 +33,7 @@ "name": { "en-US": "MinV1" }, - "address": "https://min-v1.org", + "address": "https://min-v1.org/repo", "description": { "en-US": "This is a repo with minimal data." }, diff --git a/libs/sharedTest/src/main/assets/index-min-v1.json b/libs/sharedTest/src/main/assets/index-min-v1.json index 63d8aacb4..eda229dff 100644 --- a/libs/sharedTest/src/main/assets/index-min-v1.json +++ b/libs/sharedTest/src/main/assets/index-min-v1.json @@ -4,7 +4,7 @@ "version": 1, "name": "MinV1", "icon": "min-v1.png", - "address": "https://min-v1.org", + "address": "https://min-v1.org/repo", "description": "This is a repo with minimal data." }, "requests": { diff --git a/libs/sharedTest/src/main/assets/index-min-v2.json b/libs/sharedTest/src/main/assets/index-min-v2.json index 43973741f..4f14bedc9 100644 --- a/libs/sharedTest/src/main/assets/index-min-v2.json +++ b/libs/sharedTest/src/main/assets/index-min-v2.json @@ -10,7 +10,7 @@ "size": 0 } }, - "address": "https://min-v1.org", + "address": "https://min-v1.org/repo", "description": { "en-US": "This is a repo with minimal data." }, diff --git a/libs/sharedTest/src/main/kotlin/org/fdroid/test/TestDataV1.kt b/libs/sharedTest/src/main/kotlin/org/fdroid/test/TestDataV1.kt index 2e2f4d8ce..a8dafcef3 100644 --- a/libs/sharedTest/src/main/kotlin/org/fdroid/test/TestDataV1.kt +++ b/libs/sharedTest/src/main/kotlin/org/fdroid/test/TestDataV1.kt @@ -29,7 +29,7 @@ object TestDataMinV1 { version = 1, name = "MinV1", icon = "min-v1.png", - address = "https://min-v1.org", + address = "https://min-v1.org/repo", description = "This is a repo with minimal data.", ) diff --git a/libs/sharedTest/src/main/kotlin/org/fdroid/test/TestDataV2.kt b/libs/sharedTest/src/main/kotlin/org/fdroid/test/TestDataV2.kt index 2d4fc07f2..2c49cd58d 100644 --- a/libs/sharedTest/src/main/kotlin/org/fdroid/test/TestDataV2.kt +++ b/libs/sharedTest/src/main/kotlin/org/fdroid/test/TestDataV2.kt @@ -123,7 +123,7 @@ object TestDataMinV2 { size = 0, ), ), - address = "https://min-v1.org", + address = "https://min-v1.org/repo", description = mapOf(LOCALE to "This is a repo with minimal data."), )