mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-10 23:21:59 +01:00
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:
@@ -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>())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user