From a58c38590a5349d37409a0fc7cb2c2cf512295b0 Mon Sep 17 00:00:00 2001 From: Joao Victor Sena Date: Thu, 24 Oct 2024 19:28:10 -0300 Subject: [PATCH] test: CheckModulesTest --- app/build.gradle.kts | 1 + .../jvsena42/floresta/FlorestaApplication.kt | 5 ++--- .../github/jvsena42/floresta/CheckModulesTest.kt | 16 ++++++++++++++++ gradle/libs.versions.toml | 1 + 4 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 app/src/test/java/com/github/jvsena42/floresta/CheckModulesTest.kt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index d43445a..cb458b3 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -55,6 +55,7 @@ dependencies { implementation(libs.koin.viewmodel) implementation(libs.koin.compose) implementation(libs.koin.android) + implementation(libs.koin.test) testImplementation(libs.junit) androidTestImplementation(libs.androidx.junit) androidTestImplementation(libs.androidx.espresso.core) diff --git a/app/src/main/java/com/github/jvsena42/floresta/FlorestaApplication.kt b/app/src/main/java/com/github/jvsena42/floresta/FlorestaApplication.kt index e43d2cb..c87c855 100644 --- a/app/src/main/java/com/github/jvsena42/floresta/FlorestaApplication.kt +++ b/app/src/main/java/com/github/jvsena42/floresta/FlorestaApplication.kt @@ -11,7 +11,6 @@ import com.github.jvsena42.floresta.domain.floresta.FlorestaDaemonImpl import com.github.jvsena42.floresta.domain.floresta.FlorestaService import com.github.jvsena42.floresta.presentation.MainViewmodel import com.github.jvsena42.floresta.presentation.ui.screens.home.HomeViewModel -import org.koin.android.ext.koin.androidApplication import org.koin.android.ext.koin.androidContext import org.koin.android.ext.koin.androidLogger import org.koin.core.context.startKoin @@ -33,7 +32,7 @@ class FlorestaApplication : Application() { } } -private val presentationModule = module { +val presentationModule = module { viewModel { MainViewmodel() } viewModel { HomeViewModel( walletRepository = get(), @@ -42,7 +41,7 @@ private val presentationModule = module { ) } } -private val domainModule = module { +val domainModule = module { single { WalletManager( dbPath = androidContext().filesDir.toString(), diff --git a/app/src/test/java/com/github/jvsena42/floresta/CheckModulesTest.kt b/app/src/test/java/com/github/jvsena42/floresta/CheckModulesTest.kt new file mode 100644 index 0000000..20b6f42 --- /dev/null +++ b/app/src/test/java/com/github/jvsena42/floresta/CheckModulesTest.kt @@ -0,0 +1,16 @@ +package com.github.jvsena42.floresta + +import org.junit.Test +import org.koin.core.annotation.KoinExperimentalAPI +import org.koin.test.KoinTest +import org.koin.test.verify.verify + +class CheckModulesTest: KoinTest { + + @OptIn(KoinExperimentalAPI::class) + @Test + fun checkAllModules() { + domainModule.verify() + presentationModule.verify() + } +} \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 51c6af3..db22655 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -33,6 +33,7 @@ koin-core = { module = "io.insert-koin:koin-core" } koin-android = { module = "io.insert-koin:koin-android" } koin-viewmodel = { module = "io.insert-koin:koin-core-viewmodel" } koin-compose = { module = "io.insert-koin:koin-androidx-compose" } +koin-test = { module = "io.insert-koin:koin-test-junit4" } [plugins] android-application = { id = "com.android.application", version.ref = "agp" }