From dbc4232dd69aaf2078b8ac7cf4f293e303da1d13 Mon Sep 17 00:00:00 2001 From: LamGC Date: Mon, 20 Jun 2022 16:01:35 +0800 Subject: [PATCH] =?UTF-8?q?test(config):=20=E8=B0=83=E6=95=B4=20BotAccount?= =?UTF-8?q?=20=E7=9A=84=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95=E4=BB=A3?= =?UTF-8?q?=E7=A0=81.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 调整代码有利于后续更新测试用例时减少出错的可能性(虽然基本不换), 修复一个词汇错误. --- scalabot-app/src/test/kotlin/AppConfigTest.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scalabot-app/src/test/kotlin/AppConfigTest.kt b/scalabot-app/src/test/kotlin/AppConfigTest.kt index 2ae9950..ad39f47 100644 --- a/scalabot-app/src/test/kotlin/AppConfigTest.kt +++ b/scalabot-app/src/test/kotlin/AppConfigTest.kt @@ -2,6 +2,7 @@ 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 @@ -26,18 +27,19 @@ internal class BotAccountTest { fun deserializerTest() { val accountId = abs(Random().nextInt()).toLong() val creatorId = abs(Random().nextInt()).toLong() - val botAccount = Gson().fromJson( + val botAccountJsonObject = Gson().fromJson( """ { "name": "TestBot", "token": "${accountId}:AAHErDroUTznQsOd_oZPJ6cQEj4Z5mGHO10", "creatorId": $creatorId } - """.trimIndent(), BotAccount::class.java + """.trimIndent(), JsonObject::class.java ) - assertEquals("TestBot", botAccount.name) - assertEquals("${accountId}:AAHErDroUTznQsOd_oZPJ6cQEj4Z5mGHO10", botAccount.token) - assertEquals(accountId, botAccount.id, "Botaccount ID does not match expectations.") + 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) }