Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Faltenreich committed Nov 29, 2024
1 parent b00804c commit ba96f8b
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.faltenreich.diaguard.navigation.system
package com.faltenreich.diaguard.shared.system

import android.content.Context
import android.content.Intent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.faltenreich.diaguard.navigation.system
package com.faltenreich.diaguard.shared.system

import org.koin.android.ext.koin.androidContext
import org.koin.dsl.module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import com.faltenreich.diaguard.shared.logging.loggerModule
import com.faltenreich.diaguard.shared.networking.networkingModule
import com.faltenreich.diaguard.shared.primitive.primitiveModule
import com.faltenreich.diaguard.shared.serialization.serializationModule
import com.faltenreich.diaguard.shared.system.systemSettingsModule
import com.faltenreich.diaguard.shared.theme.themeModule
import com.faltenreich.diaguard.statistic.statisticModule
import com.faltenreich.diaguard.tag.tagModule
Expand All @@ -43,6 +44,7 @@ fun appModules() = listOf(
databaseModule(),
networkingModule(),
dateTimeModule(),
systemSettingsModule(),
// Feature
themeModule(),
seedModule(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,11 @@ import com.faltenreich.diaguard.navigation.screen.GetTopAppBarStyleUseCase
import com.faltenreich.diaguard.navigation.screen.PopScreenUseCase
import com.faltenreich.diaguard.navigation.screen.PushScreenUseCase
import com.faltenreich.diaguard.navigation.system.OpenNotificationSettingsUseCase
import com.faltenreich.diaguard.navigation.system.systemSettingsModule
import org.koin.core.module.dsl.singleOf
import org.koin.core.module.dsl.viewModelOf
import org.koin.dsl.module

fun navigationModule() = module {
includes(systemSettingsModule())

singleOf(::Navigation)

singleOf(::CollectNavigationEventsUseCase)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.faltenreich.diaguard.navigation.system

import com.faltenreich.diaguard.shared.system.SystemSettings

class OpenNotificationSettingsUseCase(private val systemSettings: SystemSettings) {

operator fun invoke() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.faltenreich.diaguard.backup.user.write.WriteBackupFormScreen
import com.faltenreich.diaguard.measurement.category.list.MeasurementCategoryListScreen
import com.faltenreich.diaguard.navigation.bottomsheet.OpenBottomSheetUseCase
import com.faltenreich.diaguard.navigation.screen.PushScreenUseCase
import com.faltenreich.diaguard.navigation.system.SystemSettings
import com.faltenreich.diaguard.shared.system.SystemSettings
import com.faltenreich.diaguard.preference.color.ColorSchemeFormScreen
import com.faltenreich.diaguard.preference.color.ColorSchemePreference
import com.faltenreich.diaguard.preference.decimal.DecimalPlacesFormScreen
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.faltenreich.diaguard.navigation.system
package com.faltenreich.diaguard.shared.system

interface SystemSettings {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.faltenreich.diaguard.navigation.system
package com.faltenreich.diaguard.shared.system

import org.koin.core.module.Module

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.faltenreich.diaguard

import com.faltenreich.diaguard.backup.legacy.LegacyDao
import com.faltenreich.diaguard.backup.legacy.FakeLegacyDao
import com.faltenreich.diaguard.backup.legacy.LegacyDao
import com.faltenreich.diaguard.backup.seed.query.food.FoodSeedQueries
import com.faltenreich.diaguard.backup.seed.query.tag.TagSeedQueries
import com.faltenreich.diaguard.export.pdf.PdfExport
Expand All @@ -19,6 +19,8 @@ import com.faltenreich.diaguard.shared.localization.Localization
import com.faltenreich.diaguard.shared.logging.ConsoleLogger
import com.faltenreich.diaguard.shared.logging.Logger
import com.faltenreich.diaguard.shared.serialization.Serialization
import com.faltenreich.diaguard.shared.system.FakeSystemSettings
import com.faltenreich.diaguard.shared.system.SystemSettings
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.test.StandardTestDispatcher
Expand All @@ -34,6 +36,8 @@ fun testModules() = module {
single<CoroutineContext> { StandardTestDispatcher() }
single<CoroutineScope> { TestScope(context = get()) }

factory<SystemSettings> { FakeSystemSettings() }

single<BuildConfig> { FakeBuildConfig() }

single<Logger> { ConsoleLogger() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class OverviewPreferenceViewModelTest : TestSuite {
"color_scheme",
"start_screen",
"decimal_places",
"reminders",
"therapy",
"measurement_categories",
"tags",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.faltenreich.diaguard.shared.config

class FakeBuildConfig : BuildConfig {

override fun getPackageName(): String = "com.faltenreich.diaguard"

override fun getVersionCode(): Long = 1

override fun getVersionName(): String = "1.0.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.faltenreich.diaguard.shared.system

class FakeSystemSettings : SystemSettings {

override fun openNotificationSettings() = Unit
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.faltenreich.diaguard.navigation.system
package com.faltenreich.diaguard.shared.system

import org.koin.dsl.module

Expand Down

0 comments on commit ba96f8b

Please sign in to comment.