Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ccb55055 authored by Guillaume Jacquart's avatar Guillaume Jacquart
Browse files

test:4025: fix lint and unit tests

parent 1b6f9a4c
Loading
Loading
Loading
Loading
+15 −15
Original line number Diff line number Diff line
@@ -71,8 +71,9 @@ class InstallAppService : LifecycleService() {
        super.onBind(intent)
        return binder
    }
}

    private fun Status?.toAppInstallationStatus(): AppInstallationStatus {
fun Status?.toAppInstallationStatus(): AppInstallationStatus {
    return when (this) {
        Status.UPDATABLE,
        Status.INSTALLED -> AppInstallationStatus.INSTALLED
@@ -92,4 +93,3 @@ class InstallAppService : LifecycleService() {
        null -> AppInstallationStatus.UNKNOWN
    }
}
}
+45 −1
Original line number Diff line number Diff line
@@ -186,7 +186,7 @@ class CleanApkAppsRepositoryTest {
        val architectures = listOf("arm64-v8a")
        val packageName = "com.example.app"
        val appId = "id-123"
        val expectedApp = Application(_id = appId, name = "Example")
        val expectedApp = Application(_id = appId, name = "Example", is_pwa = false, source = Source.OPEN_SOURCE)

        every { SystemInfoProvider.getSupportedArchitectureList() } returns architectures
        coEvery {
@@ -244,6 +244,50 @@ class CleanApkAppsRepositoryTest {
        assertThat(result).isEqualTo(Application())
    }

    @Test
    fun `getAppDetails set source=OPEN_SOURCE for not pwa App`() = runTest {
        val packageName = "com.example.app"
        val appId = "id-123"
        val expectedApp = Application(_id = appId, name = "Example", is_pwa = false, source = Source.OPEN_SOURCE)

        every { SystemInfoProvider.getSupportedArchitectureList() } returns  listOf("arm64-v8a")
        coEvery {
            cleanApkRetrofit.checkAvailablePackages(any(), any(), any())
        } returns Response.success(Search(apps = listOf(Application(_id = appId))))
        coEvery {
            cleanApkRetrofit.getAppOrPWADetailsByID(any(), any(), any())
        } returns Response.success(CleanApkApplication(
            app = Application(_id = appId, name = "Example", is_pwa = false),
            success = true
        ))

        val result = repository.getAppDetails(packageName)

        assertThat(result).isEqualTo(expectedApp)
    }

    @Test
    fun `getAppDetails set source=PWA for pwa App`() = runTest {
        val packageName = "com.example.app"
        val appId = "id-123"
        val expectedApp = Application(_id = appId, name = "Example", is_pwa = true, source = Source.PWA)

        every { SystemInfoProvider.getSupportedArchitectureList() } returns  listOf("arm64-v8a")
        coEvery {
            cleanApkRetrofit.checkAvailablePackages(any(), any(), any())
        } returns Response.success(Search(apps = listOf(Application(_id = appId))))
        coEvery {
            cleanApkRetrofit.getAppOrPWADetailsByID(any(), any(), any())
        } returns Response.success(CleanApkApplication(
            app = Application(_id = appId, name = "Example", is_pwa = true),
            success = true
        ))

        val result = repository.getAppDetails(packageName)

        assertThat(result).isEqualTo(expectedApp)
    }

    @Test
    fun `getDownloadInfo forwards single supported architecture`() = runTest {
        every { SystemInfoProvider.getSupportedArchitecture() } returns "arm64-v8a"
+20 −0
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
 */
package foundation.e.apps.domain.install

import android.view.KeyCharacterMap
import com.aurora.gplayapi.exceptions.InternalException
import foundation.e.apps.data.Stores
import foundation.e.apps.data.application.data.Application
import foundation.e.apps.data.blockedApps.BlockedAppRepository
@@ -116,6 +118,24 @@ class GetAppDetailsUseCaseTest {
        coVerify(exactly = 0) { playStoreRepository.getAppDetails("pkg") }
    }

    @Test
    fun invoke_throwsUnavailableWhenUnavailableInAllSource() = runTest {
        every { stores.getEnabledSearchSources() } returns listOf(Source.PLAY_STORE, Source.OPEN_SOURCE, Source.PWA)
        val emptyApp = Application()

        coEvery { cleanApkAppsRepository.getAppDetails("pkg") } returns emptyApp
        coEvery { cleanApkPwaRepository.getAppDetails("pkg") } returns emptyApp
        coEvery { playStoreRepository.getAppDetails("pkg") } throws  InternalException.AppNotFound()

        assertFailsWith<UnavailableApp> {
            useCase("pkg")
        }

        coVerify { cleanApkAppsRepository.getAppDetails("pkg") }
        coVerify { cleanApkPwaRepository.getAppDetails("pkg") }
        coVerify { playStoreRepository.getAppDetails("pkg") }
    }

    @Test
    fun invoke_throwsStoreNotConfiguredWhenSourceNotEnabled() = runTest {
        every { stores.getEnabledSearchSources() } returns listOf(Source.OPEN_SOURCE)
+0 −1
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ enum class AppInstallationStatus {
    SERVICE_BUSY;

    companion object {

        fun parse(raw: String): AppInstallationStatus {
            return runCatching {
                AppInstallationStatus.valueOf(raw)