This commit is contained in:
7 files changed
+164
-82
No files matched your search
@@ -318,14 +318,6 @@ class RawRpcParamsRatchetTest {
|
||||
listOf(
|
||||
"data/ws/HermesWsClient.kt::CLIENT_CAPABILITIES",
|
||||
"data/ws/ModelOptionsRepository.kt::MODEL_OPTIONS",
|
||||
"ui/bots/BotsViewModel.kt::PROFILES_CONFIGURE",
|
||||
"ui/bots/BotsViewModel.kt::PROFILES_CONFIGURE",
|
||||
"ui/bots/BotsViewModel.kt::PROFILES_CONFIGURE",
|
||||
"ui/bots/BotsViewModel.kt::PROFILES_LIST",
|
||||
"ui/bots/group/GroupChatViewModel.kt::PROFILES_CONFIGURE",
|
||||
"ui/bots/group/GroupChatViewModel.kt::PROFILES_CONFIGURE",
|
||||
"ui/bots/group/GroupChatViewModel.kt::PROFILES_CONFIGURE",
|
||||
"ui/bots/group/GroupChatViewModel.kt::PROFILES_LIST",
|
||||
"ui/chat/ChatModelSwitchDelegate.kt::CONFIG_SET",
|
||||
"ui/chat/ChatModelSwitchDelegate.kt::CONFIG_SET",
|
||||
"ui/chat/ChatModelSwitchDelegate.kt::CONFIG_SET",
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.m57.hermescontrol.data.ws.contract
|
||||
|
||||
import com.m57.hermescontrol.data.remote.OkHttpProvider
|
||||
import kotlinx.serialization.json.buildJsonObject
|
||||
import kotlinx.serialization.json.put
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class ProfilesTypesTest {
|
||||
private fun encode(params: ProfilesConfigureParams) =
|
||||
OkHttpProvider.json.encodeToJsonElement(ProfilesConfigureParams.serializer(), params)
|
||||
|
||||
@Test
|
||||
fun configureEncodesNameAndUiMetaOnly() {
|
||||
val meta = buildJsonObject { put("hermes-bots-groups", buildJsonObject { put("version", 3) }) }
|
||||
assertEquals(
|
||||
buildJsonObject {
|
||||
put("name", "default")
|
||||
put("ui_meta", meta)
|
||||
},
|
||||
encode(ProfilesConfigureParams(name = "default", uiMeta = meta)),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun configureIncludesSoulWhenPresent() {
|
||||
val meta = buildJsonObject { put("hermes-bots", buildJsonObject { put("title", "Scout") }) }
|
||||
assertEquals(
|
||||
buildJsonObject {
|
||||
put("name", "scout")
|
||||
put("ui_meta", meta)
|
||||
put("soul", "# Scout")
|
||||
},
|
||||
encode(ProfilesConfigureParams(name = "scout", uiMeta = meta, soul = "# Scout")),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun listEncodesAsEmptyObject() {
|
||||
assertEquals(
|
||||
buildJsonObject { },
|
||||
OkHttpProvider.json.encodeToJsonElement(ProfilesListParams.serializer(), ProfilesListParams),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun descriptorsAreRegisteredWithContractNames() {
|
||||
assertTrue(RpcMethods.PROFILES_LIST in RpcMethods.all)
|
||||
assertTrue(RpcMethods.PROFILES_CONFIGURE in RpcMethods.all)
|
||||
assertEquals("profiles.list", RpcMethods.PROFILES_LIST.name)
|
||||
assertEquals("profiles.configure", RpcMethods.PROFILES_CONFIGURE.name)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user