From: David ‘Bombe’ Roden Date: Wed, 10 Jul 2019 19:43:19 +0000 (+0200) Subject: ✅ Test for correct l10n in SoneModule X-Git-Tag: v81^2~196 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=18e619b28421c8222b743c779d0b2e55c1bc1bd9;p=Sone.git ✅ Test for correct l10n in SoneModule --- diff --git a/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt b/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt index 6a349eb..18f4b95 100644 --- a/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt +++ b/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt @@ -6,6 +6,7 @@ import com.google.inject.* import com.google.inject.matcher.* import com.google.inject.name.Names.* import com.google.inject.spi.* +import freenet.l10n.* import net.pterodactylus.sone.database.* import net.pterodactylus.sone.database.memory.* import net.pterodactylus.sone.freenet.wot.* @@ -49,6 +50,7 @@ class SoneModule(private val sonePlugin: SonePlugin) : AbstractModule() { bind(PluginYear::class.java).toInstance(PluginYear(sonePlugin.year)) bind(PluginHomepage::class.java).toInstance(PluginHomepage(sonePlugin.homepage)) bind(Database::class.java).to(MemoryDatabase::class.java).`in`(Singleton::class.java) + bind(BaseL10n::class.java).toInstance(sonePlugin.l10n().base) loaders?.let { bind(Loaders::class.java).toInstance(it) } bindListener(Matchers.any(), object : TypeListener { diff --git a/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt b/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt index 62f947c..0b8ef04 100644 --- a/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt @@ -4,6 +4,7 @@ import com.google.common.base.* import com.google.common.eventbus.* import com.google.inject.Guice.* import com.google.inject.name.Names.* +import freenet.l10n.* import net.pterodactylus.sone.database.* import net.pterodactylus.sone.database.memory.* import net.pterodactylus.sone.freenet.wot.* @@ -12,9 +13,9 @@ import net.pterodactylus.util.config.* import net.pterodactylus.util.version.Version import org.hamcrest.MatcherAssert.* import org.hamcrest.Matchers.* -import org.junit.* import java.io.* import java.util.concurrent.atomic.* +import kotlin.test.* const val versionString = "v80" @@ -24,15 +25,17 @@ class SoneModuleTest { private val pluginVersion = Version("", 80) private val pluginYear = 2019 private val pluginHomepage = "home://page" + private val l10n = deepMock() private val sonePlugin = mock().apply { whenever(version).thenReturn(versionString) whenever(year).thenReturn(pluginYear) whenever(homepage).thenReturn(pluginHomepage) + whenever(l10n()).thenReturn(l10n) } private val injector by lazy { createInjector(SoneModule(sonePlugin)) } - @After + @AfterTest fun removePropertiesFromCurrentDirectory() { File(currentDir, "sone.properties").delete() } @@ -134,6 +137,11 @@ class SoneModuleTest { } @Test + fun `base l10n is bound correctly`() { + assertThat(injector.getInstance(), sameInstance(l10n.base)) + } + + @Test fun `default loader is used without dev options`() { assertThat(injector.getInstance(), instanceOf(DefaultLoaders::class.java)) }