discord-kagebot/src/test/kotlin/moe/kageru/kagebot/ConfigTest.kt

39 lines
1.2 KiB
Kotlin
Raw Normal View History

2019-06-08 21:14:57 +02:00
package moe.kageru.kagebot
import io.kotlintest.shouldBe
2019-06-08 21:52:47 +02:00
import io.kotlintest.shouldNotBe
import io.kotlintest.specs.ShouldSpec
import io.mockk.every
import io.mockk.mockk
2019-07-13 15:39:50 +02:00
import moe.kageru.kagebot.config.Config
import moe.kageru.kagebot.features.SetConfigFeature
2019-06-08 21:52:47 +02:00
class ConfigTest : ShouldSpec({
TestUtil.prepareTestEnvironment()
"should properly parse test config" {
2019-07-13 15:39:50 +02:00
Config.systemConfig shouldNotBe null
Config.localization shouldNotBe null
Config.features shouldNotBe null
Config.commands.size shouldBe 2
}
"should parse test config via command" {
val denied = "denied"
val testConfig = """
[localization]
permissionDenied = "$denied"
redirectedMessage = "says"
messageDeleted = "dongered"
[[command]]
response = "this command is broken"
""".trimIndent()
val message = TestUtil.mockMessage("anything")
every { message.messageAttachments } returns listOf(mockk {
every { url.openStream().readAllBytes() } returns testConfig.toByteArray()
})
SetConfigFeature().handle(message)
Config.localization.permissionDenied shouldBe denied
}
2019-07-13 14:52:05 +02:00
})