Move tests to app level as they are not working in a library module

This commit is contained in:
Wolf-Martell Montwé 2024-01-18 18:01:47 +01:00
parent fb5cc67977
commit ccd7873676
No known key found for this signature in database
GPG key ID: 6D45B21512ACBF72
4 changed files with 10 additions and 32 deletions

View file

@ -19,6 +19,12 @@ dependencies {
debugImplementation(projects.backend.demo)
implementation(libs.androidx.work.runtime)
testImplementation(libs.robolectric)
// Required for DependencyInjectionTest to be able to resolve OpenPgpApiManager
testImplementation(projects.plugins.openpgpApiLib.openpgpApi)
testImplementation(projects.feature.account.setup)
}
android {

View file

@ -1,4 +1,4 @@
package com.fsck.k9
package app.k9mail
import android.view.ContextThemeWrapper
import androidx.lifecycle.LifecycleOwner
@ -29,10 +29,8 @@ import org.mockito.kotlin.mock
import org.openintents.openpgp.OpenPgpApiManager
import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment
import org.robolectric.annotation.Config
@RunWith(RobolectricTestRunner::class)
@Config(application = TestApp::class)
class DependencyInjectionTest : AutoCloseKoinTest() {
private val lifecycleOwner = mock<LifecycleOwner> {
on { lifecycle } doReturn mock()

View file

@ -1,4 +1,4 @@
package com.fsck.k9.widget.unread
package app.k9mail.unread
import android.content.Context
import assertk.assertThat
@ -6,7 +6,6 @@ import assertk.assertions.isEqualTo
import assertk.assertions.isNull
import com.fsck.k9.Account
import com.fsck.k9.Preferences
import com.fsck.k9.TestApp
import com.fsck.k9.controller.MessageCounts
import com.fsck.k9.controller.MessageCountsProvider
import com.fsck.k9.mailstore.Folder
@ -15,6 +14,8 @@ import com.fsck.k9.mailstore.FolderType
import com.fsck.k9.search.SearchAccount
import com.fsck.k9.ui.folders.FolderNameFormatter
import com.fsck.k9.ui.messagelist.DefaultFolderProvider
import com.fsck.k9.widget.unread.UnreadWidgetConfiguration
import com.fsck.k9.widget.unread.UnreadWidgetDataProvider
import org.junit.Test
import org.junit.runner.RunWith
import org.koin.test.AutoCloseKoinTest
@ -22,10 +23,8 @@ import org.mockito.kotlin.doReturn
import org.mockito.kotlin.mock
import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment
import org.robolectric.annotation.Config
@RunWith(RobolectricTestRunner::class)
@Config(application = TestApp::class)
class UnreadWidgetDataProviderTest : AutoCloseKoinTest() {
private val context: Context = RuntimeEnvironment.getApplication()
private val account = createAccount()

View file

@ -1,25 +0,0 @@
package com.fsck.k9
import app.k9mail.core.common.oauth.OAuthConfigurationFactory
import com.fsck.k9.backend.BackendFactory
import org.koin.core.module.Module
import org.koin.core.qualifier.named
import org.koin.dsl.module
class TestApp : CommonApp() {
override fun provideAppModule(): Module = module {
single(named("ClientIdAppName")) { "ClientIdAppName" }
single(named("ClientIdAppVersion")) { "ClientIdAppVersion" }
single {
AppConfig(
componentsToDisable = emptyList(),
)
}
single<Map<String, BackendFactory>>(named("developmentBackends")) {
emptyMap()
}
single<OAuthConfigurationFactory> {
OAuthConfigurationFactory { emptyMap() }
}
}
}