From 9cdbc929758ee2271e7d9a335f596ef4d6724ddb Mon Sep 17 00:00:00 2001 From: austinried <4966622+austinried@users.noreply.github.com> Date: Sun, 27 Sep 2026 07:15:03 +0000 Subject: [PATCH] bind the download engine by its interface in Koin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `single { SystemDownloadEngine(...) }` registers the concrete class, but DownloadRepository asks for the DownloadEngine interface, so resolving PlaybackController threw NoDefinitionFoundException and the app died on launch with a Koin InstanceCreationException. It is now `single`, the way the other interface singletons in the module are declared. Nothing in the suite ever started Koin — the repository tests build the repository directly with a fake — which is why a launch-crashing binding got through. AppModuleTest now resolves the playback graph from the real module, and it failed with the same NoDefinitionFoundException before this fix. --- .../main/kotlin/com/subtracks/di/AppModule.kt | 3 +- .../kotlin/com/subtracks/di/AppModuleTest.kt | 33 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 app/src/test/kotlin/com/subtracks/di/AppModuleTest.kt diff --git a/app/src/main/kotlin/com/subtracks/di/AppModule.kt b/app/src/main/kotlin/com/subtracks/di/AppModule.kt index 2395c4ba..67d49c5e 100644 --- a/app/src/main/kotlin/com/subtracks/di/AppModule.kt +++ b/app/src/main/kotlin/com/subtracks/di/AppModule.kt @@ -6,6 +6,7 @@ import android.os.Handler import android.os.Looper import android.widget.Toast import com.subtracks.data.db.createAndroidDatabase +import com.subtracks.data.download.DownloadEngine import com.subtracks.data.download.SystemDownloadEngine import com.subtracks.data.net.networkMode import com.subtracks.data.prefs.createUserPreferences @@ -48,7 +49,7 @@ fun appModule( single { ArtworkSeedRepository(get()) } single { SyncManager(get(), get(), get()) } single { QueueRepository(get()) } - single { SystemDownloadEngine(context.applicationContext) } + single { SystemDownloadEngine(context.applicationContext) } single { DownloadRepository( db = get(), diff --git a/app/src/test/kotlin/com/subtracks/di/AppModuleTest.kt b/app/src/test/kotlin/com/subtracks/di/AppModuleTest.kt new file mode 100644 index 00000000..5386a34f --- /dev/null +++ b/app/src/test/kotlin/com/subtracks/di/AppModuleTest.kt @@ -0,0 +1,33 @@ +package com.subtracks.di + +import android.content.Context +import androidx.test.core.app.ApplicationProvider +import androidx.test.ext.junit.runners.AndroidJUnit4 +import com.subtracks.data.repo.DownloadRepository +import com.subtracks.playback.PlaybackController +import okhttp3.OkHttpClient +import org.junit.After +import org.junit.Assert.assertNotNull +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith +import org.koin.core.context.startKoin +import org.koin.core.context.stopKoin + +@RunWith(AndroidJUnit4::class) +class AppModuleTest { + @Before + fun setUp() = stopKoin() + + @After + fun tearDown() = stopKoin() + + @Test + fun theModuleResolvesThePlaybackGraph() { + val context = ApplicationProvider.getApplicationContext() + val koin = startKoin { modules(appModule(context, OkHttpClient())) }.koin + + assertNotNull(koin.get()) + assertNotNull(koin.get()) + } +}