bind the download engine by its interface in Koin

`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<DownloadEngine>`, 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.
This commit is contained in:
austinried
2026-10-04 00:30:01 +00:00
parent 2520c60f5a
commit 9cdbc92975
2 changed files with 35 additions and 1 deletions
@@ -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<ArtworkSeedStore> { ArtworkSeedRepository(get()) }
single { SyncManager(get(), get(), get()) }
single { QueueRepository(get()) }
single { SystemDownloadEngine(context.applicationContext) }
single<DownloadEngine> { SystemDownloadEngine(context.applicationContext) }
single {
DownloadRepository(
db = get(),
@@ -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<Context>()
val koin = startKoin { modules(appModule(context, OkHttpClient())) }.koin
assertNotNull(koin.get<DownloadRepository>())
assertNotNull(koin.get<PlaybackController>())
}
}