Issue#13 Remove BaseUrlProvider
This commit is contained in:
parent
163bb8cd10
commit
8d33f77cec
4 changed files with 12 additions and 35 deletions
|
|
@ -1,8 +1,8 @@
|
||||||
package org.fnives.test.showcase
|
package org.fnives.test.showcase
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import org.fnives.test.showcase.di.BaseUrlProvider
|
|
||||||
import org.fnives.test.showcase.di.createAppModules
|
import org.fnives.test.showcase.di.createAppModules
|
||||||
|
import org.fnives.test.showcase.model.network.BaseUrl
|
||||||
import org.koin.android.ext.koin.androidContext
|
import org.koin.android.ext.koin.androidContext
|
||||||
import org.koin.core.context.startKoin
|
import org.koin.core.context.startKoin
|
||||||
|
|
||||||
|
|
@ -10,9 +10,10 @@ class TestShowcaseApplication : Application() {
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
|
val baseUrl = BaseUrl(BuildConfig.BASE_URL)
|
||||||
startKoin {
|
startKoin {
|
||||||
androidContext(this@TestShowcaseApplication)
|
androidContext(this@TestShowcaseApplication)
|
||||||
modules(createAppModules(BaseUrlProvider.get()))
|
modules(createAppModules(baseUrl))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
package org.fnives.test.showcase.di
|
|
||||||
|
|
||||||
import org.fnives.test.showcase.BuildConfig
|
|
||||||
import org.fnives.test.showcase.model.network.BaseUrl
|
|
||||||
|
|
||||||
object BaseUrlProvider {
|
|
||||||
|
|
||||||
fun get() = BaseUrl(BuildConfig.BASE_URL)
|
|
||||||
}
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
package org.fnives.test.showcase.di
|
|
||||||
|
|
||||||
import org.fnives.test.showcase.model.network.BaseUrl
|
|
||||||
import org.fnives.test.showcase.testutils.configuration.SpecificTestConfigurationsFactory
|
|
||||||
|
|
||||||
object BaseUrlProvider {
|
|
||||||
|
|
||||||
fun get() = BaseUrl(SpecificTestConfigurationsFactory.createServerTypeConfiguration().url)
|
|
||||||
}
|
|
||||||
|
|
@ -1,29 +1,23 @@
|
||||||
package org.fnives.test.showcase.testutils
|
package org.fnives.test.showcase.testutils
|
||||||
|
|
||||||
import androidx.test.core.app.ApplicationProvider
|
|
||||||
import org.fnives.test.showcase.TestShowcaseApplication
|
|
||||||
import org.fnives.test.showcase.di.BaseUrlProvider
|
|
||||||
import org.fnives.test.showcase.di.createAppModules
|
|
||||||
import org.junit.rules.TestRule
|
import org.junit.rules.TestRule
|
||||||
import org.junit.runner.Description
|
import org.junit.runner.Description
|
||||||
import org.junit.runners.model.Statement
|
import org.junit.runners.model.Statement
|
||||||
import org.koin.android.ext.koin.androidContext
|
|
||||||
import org.koin.core.context.GlobalContext
|
|
||||||
import org.koin.core.context.startKoin
|
|
||||||
import org.koin.core.context.stopKoin
|
import org.koin.core.context.stopKoin
|
||||||
|
|
||||||
class ReloadKoinModulesIfNecessaryTestRule : TestRule {
|
class ReloadKoinModulesIfNecessaryTestRule : TestRule {
|
||||||
override fun apply(base: Statement, description: Description): Statement =
|
override fun apply(base: Statement, description: Description): Statement =
|
||||||
object : Statement() {
|
object : Statement() {
|
||||||
override fun evaluate() {
|
override fun evaluate() {
|
||||||
if (GlobalContext.getOrNull() == null) {
|
// TODO
|
||||||
val application =
|
// if (GlobalContext.getOrNull() == null) {
|
||||||
ApplicationProvider.getApplicationContext<TestShowcaseApplication>()
|
// val application =
|
||||||
startKoin {
|
// ApplicationProvider.getApplicationContext<TestShowcaseApplication>()
|
||||||
androidContext(application)
|
// startKoin {
|
||||||
modules(createAppModules(BaseUrlProvider.get()))
|
// androidContext(application)
|
||||||
}
|
// modules(createAppModules(BaseUrlProvider.get()))
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
try {
|
try {
|
||||||
base.evaluate()
|
base.evaluate()
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue