2019-06-08 21:14:57 +02:00
package moe.kageru.kagebot
2019-06-14 23:16:31 +02:00
import io.kotlintest.shouldBe
2019-06-08 21:52:47 +02:00
import io.kotlintest.shouldNotBe
2019-11-24 14:03:45 +01:00
import io.kotlintest.specs.StringSpec
2019-07-17 21:37:57 +02:00
import io.mockk.every
import io.mockk.mockk
2019-07-13 15:39:50 +02:00
import moe.kageru.kagebot.config.Config
2019-10-18 19:34:41 +02:00
import moe.kageru.kagebot.config.LocalizationSpec
2019-10-06 16:14:01 +02:00
import moe.kageru.kagebot.config.SystemSpec
2019-07-17 21:37:57 +02:00
import moe.kageru.kagebot.features.SetConfigFeature
2019-10-06 16:14:01 +02:00
import java.awt.Color
2019-06-08 21:52:47 +02:00
2019-07-17 23:42:12 +02:00
@ExperimentalStdlibApi
2019-11-24 14:03:45 +01:00
class ConfigTest : StringSpec ( ) {
init {
" should properly parse test config " {
TestUtil . prepareTestEnvironment ( )
Config . system [ SystemSpec . serverId ] shouldNotBe null
SystemSpec . color shouldBe Color . decode ( " #1793d0 " )
Config . features . welcome !! . embed shouldNotBe null
Config . commands . size shouldBe 3
}
2019-07-17 21:37:57 +02:00
2019-11-24 14:03:45 +01:00
" should parse test config via command " {
val redir = " says "
val testConfig = """
2019-11-14 15:10:30 +01:00
[localization]
redirectedMessage = " $redir "
messageDeleted = " dongered "
timeout = " timeout "
""" .trimIndent()
2019-11-24 14:03:45 +01:00
val message = TestUtil . mockMessage ( " anything " )
every { message . messageAttachments } returns listOf ( mockk {
every { url . openStream ( ) . readAllBytes ( ) } returns testConfig . toByteArray ( )
} )
SetConfigFeature ( ) . handle ( message )
Config . localization [ LocalizationSpec . redirectedMessage ] shouldBe redir
}
2019-11-14 15:10:30 +01:00
}
2019-11-24 14:03:45 +01:00
}