mirror of
https://github.com/LamGC/ScalaBot.git
synced 2025-07-03 05:47:24 +00:00
refactor(config): 将与配置相关的内容迁移到 scalabot-meta 模块.
通过将配置迁移到单独的模块, 可以方便使用其他程序扩展 ScaleBot, 而不仅仅是让 ScaleBot 成为扩展的平台. BREAKING CHANGE: 与配置有关的 Class 移动到了 scalabot-meta 模块. 目前仅所有配置类(以 `Config` 结尾的 Class)和相应的序列化类(以 `Serializer` 结尾的)都迁移到了 meta 模块, 但其工具方法则作为扩展函数保留在 app 模块中. 这么做的好处是为了方便其他应用(例如 ScalaBot 外部管理程序)根据需要生成配置文件. scalabot-meta 将会作为依赖项发布, 可根据需要获取 ScalaBot-meta 生成 ScalaBot 的配置. 此次改动普通用户无需迁移.
This commit is contained in:
@ -1,50 +1,16 @@
|
||||
package net.lamgc.scalabot
|
||||
|
||||
import com.github.stefanbirkner.systemlambda.SystemLambda
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.JsonObject
|
||||
import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import org.junit.jupiter.api.io.TempDir
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import kotlin.math.abs
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNotNull
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
internal class BotAccountTest {
|
||||
|
||||
@Test
|
||||
fun `id getter`() {
|
||||
val accountId = abs(Random().nextInt()).toLong()
|
||||
assertEquals(accountId, BotAccount("Test", "${accountId}:AAHErDroUTznQsOd_oZPJ6cQEj4Z5mGHO10", 0).id)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun deserializerTest() {
|
||||
val accountId = abs(Random().nextInt()).toLong()
|
||||
val creatorId = abs(Random().nextInt()).toLong()
|
||||
val botAccountJsonObject = Gson().fromJson(
|
||||
"""
|
||||
{
|
||||
"name": "TestBot",
|
||||
"token": "${accountId}:AAHErDroUTznQsOd_oZPJ6cQEj4Z5mGHO10",
|
||||
"creatorId": $creatorId
|
||||
}
|
||||
""".trimIndent(), JsonObject::class.java
|
||||
)
|
||||
val botAccount = Gson().fromJson(botAccountJsonObject, BotAccount::class.java)
|
||||
assertEquals(botAccountJsonObject["name"].asString, botAccount.name)
|
||||
assertEquals(botAccountJsonObject["token"].asString, botAccount.token)
|
||||
assertEquals(accountId, botAccount.id, "BotAccount ID does not match expectations.")
|
||||
assertEquals(creatorId, botAccount.creatorId)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal class AppPathsTest {
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user