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-07-13 15:32:23 +02:00
import io.kotlintest.specs.ShouldSpec
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-07-13 15:32:23 +02:00
class ConfigTest : ShouldSpec ( {
2019-06-14 23:16:31 +02:00
TestUtil . prepareTestEnvironment ( )
" should properly parse test config " {
2019-10-18 19:34:41 +02:00
Config . system [ SystemSpec . serverId ] shouldNotBe null
2019-10-06 16:14:01 +02:00
SystemSpec . color shouldBe Color . decode ( " #1793d0 " )
2019-07-13 15:39:50 +02:00
Config . features shouldNotBe null
2019-07-25 21:24:46 +02:00
Config . commands . size shouldBe 3
2019-06-12 23:43:36 +02:00
}
2019-07-17 21:37:57 +02:00
" should parse test config via command " {
val denied = " denied "
val testConfig = """
[localization]
permissionDenied = " $denied "
redirectedMessage = " says "
messageDeleted = " dongered "
2019-07-25 21:24:46 +02:00
timeout = " timeout "
2019-07-17 21:37:57 +02:00
""" .trimIndent()
val message = TestUtil . mockMessage ( " anything " )
every { message . messageAttachments } returns listOf ( mockk {
every { url . openStream ( ) . readAllBytes ( ) } returns testConfig . toByteArray ( )
} )
SetConfigFeature ( ) . handle ( message )
2019-10-18 19:34:41 +02:00
Config . localization [ LocalizationSpec . permissionDenied ] shouldBe denied
2019-07-17 21:37:57 +02:00
}
2019-07-13 14:52:05 +02:00
} )