kageru
d6492bae8f
The entire config parsing is now rewritten. This entirely removes toml4j in favor of Konf. It also removes all remaining RawConfig logic.
41 lines
1.3 KiB
Kotlin
41 lines
1.3 KiB
Kotlin
package moe.kageru.kagebot
|
|
|
|
import io.kotlintest.shouldBe
|
|
import io.kotlintest.shouldNotBe
|
|
import io.kotlintest.specs.ShouldSpec
|
|
import io.mockk.every
|
|
import io.mockk.mockk
|
|
import moe.kageru.kagebot.config.Config
|
|
import moe.kageru.kagebot.config.LocalizationSpec
|
|
import moe.kageru.kagebot.config.SystemSpec
|
|
import moe.kageru.kagebot.features.SetConfigFeature
|
|
import java.awt.Color
|
|
|
|
@ExperimentalStdlibApi
|
|
class ConfigTest : ShouldSpec({
|
|
TestUtil.prepareTestEnvironment()
|
|
"should properly parse test config" {
|
|
Config.system[SystemSpec.serverId] shouldNotBe null
|
|
SystemSpec.color shouldBe Color.decode("#1793d0")
|
|
Config.features.welcome!!.embed shouldNotBe null
|
|
Config.commands.size shouldBe 3
|
|
}
|
|
|
|
"should parse test config via command" {
|
|
val denied = "denied"
|
|
val testConfig = """
|
|
[localization]
|
|
permissionDenied = "$denied"
|
|
redirectedMessage = "says"
|
|
messageDeleted = "dongered"
|
|
timeout = "timeout"
|
|
""".trimIndent()
|
|
val message = TestUtil.mockMessage("anything")
|
|
every { message.messageAttachments } returns listOf(mockk {
|
|
every { url.openStream().readAllBytes() } returns testConfig.toByteArray()
|
|
})
|
|
SetConfigFeature().handle(message)
|
|
Config.localization[LocalizationSpec.permissionDenied] shouldBe denied
|
|
}
|
|
})
|