Skip to content

Commit

Permalink
fix: Remove tests for config namespaces, subserializers, they are no …
Browse files Browse the repository at this point in the history
…longer supported
  • Loading branch information
0ffz committed Feb 23, 2025
1 parent ff49b79 commit 66ee74f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class ComponentIdSerializerTest {
subclass(B::class)
subclass(SubSerializers::class)
}
provideConfig(PolymorphicListAsMapSerializer.Config<Any>(namespaces = listOf("test")))
})

val mapSerializer = PolymorphicListAsMapSerializer(PolymorphicSerializer(Components::class))
Expand All @@ -54,36 +53,4 @@ class ComponentIdSerializerTest {
""".trimIndent()
format.decodeFromString(mapSerializer, file) shouldBe listOf(A, B)
}

@Test
fun `should support subkey syntax`() {
val file =
"""
test:thing.*:
a: {}
b: {}
""".trimIndent()
format.decodeFromString(mapSerializer, file) shouldBe listOf(A, B)
}

@Test
fun `should support importing namespaces`() {
val file =
"""
thing.a: {}
thing.b: {}
""".trimIndent()
format.decodeFromString(mapSerializer, file) shouldBe listOf(A, B)
}

@Test
fun `should pass namespaces to child serializers`() {
val file =
"""
"subserializers":
"components":
"thing.a": {}
""".trimIndent()
format.decodeFromString(mapSerializer, file) shouldBe listOf(SubSerializers(listOf(A)))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,12 @@ class GearyEntityComponentIdSerializerTest : GearyTest() {
val format = YamlFormat(getAddon(SerializableComponents).serializers.module)
val file =
"""
thing.a: {}
test:thing.a: {}
""".trimIndent()

// act
val entity =
format.decodeFromString(GearyEntitySerializer(), file, overrideSerializersModule = SerializersModule {
provideConfig(PolymorphicListAsMapSerializer.Config<Any>(namespaces = listOf("test")))
})
format.decodeFromString(GearyEntitySerializer(), file)

// assert
entity.getAll() shouldContainExactly listOf(A)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ open class PolymorphicListAsMapSerializer<T : Any>(

val polymorphicSerializer = serializer as? PolymorphicSerializer<T> ?: error("Serializer is not polymorphic")

override val descriptor = MapSerializer(String.serializer(), ContextualSerializer(Any::class)).descriptor
override val descriptor = YamlMap.serializer().descriptor

override fun deserialize(decoder: Decoder): List<T> {
val components = mutableListOf<T>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import com.mineinabyss.geary.datatypes.ComponentId
import com.mineinabyss.geary.helpers.componentId
import com.mineinabyss.geary.modules.Geary
import com.mineinabyss.geary.serialization.ComponentSerializers
import com.mineinabyss.geary.serialization.SerializableComponents
import kotlinx.serialization.Contextual
import kotlinx.serialization.KSerializer
import kotlinx.serialization.descriptors.PrimitiveKind
Expand All @@ -19,7 +18,7 @@ typealias SerializableComponentId = @Contextual ComponentId

class ComponentIdSerializer(
val componentSerializers: ComponentSerializers,
val world: Geary
val world: Geary,
) : KSerializer<SerializableComponentId> {
override val descriptor = PrimitiveSerialDescriptor("EventComponent", PrimitiveKind.STRING)

Expand Down

0 comments on commit 66ee74f

Please sign in to comment.