From b0c4850248581e090bd89fa828771e925be8a6b2 Mon Sep 17 00:00:00 2001 From: Danielle Voznyy Date: Thu, 25 Jul 2024 18:50:36 -0400 Subject: [PATCH] fix: Fix failing tests and build --- addons/geary-actions/build.gradle.kts | 11 +++++++++++ .../geary/actions/actions/EnsureAction.kt | 11 ++++++----- .../geary/actions}/ConfigEntityObserversTests.kt | 13 +++++-------- .../kotlin/com/mineinabyss/geary/prefabs/Prefabs.kt | 1 - 4 files changed, 22 insertions(+), 14 deletions(-) rename addons/{geary-prefabs/src/jvmTest/kotlin/com/mineinabyss/geary/prefabs/observers => geary-actions/src/jvmTest/kotlin/com/mineinabyss/geary/actions}/ConfigEntityObserversTests.kt (86%) diff --git a/addons/geary-actions/build.gradle.kts b/addons/geary-actions/build.gradle.kts index 57b20c4e..ac29d641 100644 --- a/addons/geary-actions/build.gradle.kts +++ b/addons/geary-actions/build.gradle.kts @@ -15,5 +15,16 @@ kotlin { implementation(idofrontLibs.idofront.di) } } + val commonTest by getting { + dependencies { + implementation(kotlin("test")) + implementation(idofrontLibs.kotlinx.coroutines.test) + implementation(idofrontLibs.kotest.assertions) + implementation(idofrontLibs.kotest.property) + implementation(idofrontLibs.idofront.di) + implementation(project(":geary-core")) + implementation(project(":geary-serialization")) + } + } } } diff --git a/addons/geary-actions/src/commonMain/kotlin/com/mineinabyss/geary/actions/actions/EnsureAction.kt b/addons/geary-actions/src/commonMain/kotlin/com/mineinabyss/geary/actions/actions/EnsureAction.kt index 6b5afcd8..c7031d6c 100644 --- a/addons/geary-actions/src/commonMain/kotlin/com/mineinabyss/geary/actions/actions/EnsureAction.kt +++ b/addons/geary-actions/src/commonMain/kotlin/com/mineinabyss/geary/actions/actions/EnsureAction.kt @@ -3,6 +3,7 @@ package com.mineinabyss.geary.actions.actions import com.mineinabyss.geary.actions.Action import com.mineinabyss.geary.actions.ActionsCancelledException import com.mineinabyss.geary.actions.ActionGroupContext +import com.mineinabyss.geary.actions.Condition import com.mineinabyss.geary.actions.event_binds.EventBind import com.mineinabyss.geary.helpers.componentId import com.mineinabyss.geary.serialization.serializers.InnerSerializer @@ -16,15 +17,15 @@ class EnsureAction( val conditions: SerializedComponents, ) : Action { @Transient - private val flat = conditions.map { EventBind.CachedEvent(componentId(it::class), it) } + private val flat = conditions.map { componentId(it::class) to it } override fun ActionGroupContext.execute() { - flat.forEach { - when (val condition = it.data) { - is Conwdition -> with(condition) { + flat.forEach { (id, data) -> + when (data) { + is Condition -> with(data) { if(!execute()) throw ActionsCancelledException() } - else -> entity.emit(it.componentId, it.data) //TODO use geary condition system if we get one + else -> entity.emit(id, data) //TODO use geary condition system if we get one } } } diff --git a/addons/geary-prefabs/src/jvmTest/kotlin/com/mineinabyss/geary/prefabs/observers/ConfigEntityObserversTests.kt b/addons/geary-actions/src/jvmTest/kotlin/com/mineinabyss/geary/actions/ConfigEntityObserversTests.kt similarity index 86% rename from addons/geary-prefabs/src/jvmTest/kotlin/com/mineinabyss/geary/prefabs/observers/ConfigEntityObserversTests.kt rename to addons/geary-actions/src/jvmTest/kotlin/com/mineinabyss/geary/actions/ConfigEntityObserversTests.kt index 6a96e7d9..24fa165b 100644 --- a/addons/geary-prefabs/src/jvmTest/kotlin/com/mineinabyss/geary/prefabs/observers/ConfigEntityObserversTests.kt +++ b/addons/geary-actions/src/jvmTest/kotlin/com/mineinabyss/geary/actions/ConfigEntityObserversTests.kt @@ -1,9 +1,8 @@ -package com.mineinabyss.geary.prefabs.observers +package com.mineinabyss.geary.actions +import com.mineinabyss.geary.actions.event_binds.EntityObservers import com.mineinabyss.geary.modules.TestEngineModule import com.mineinabyss.geary.modules.geary -import com.mineinabyss.geary.prefabs.Prefabs -import com.mineinabyss.geary.prefabs.configuration.components.EntityObservers import com.mineinabyss.geary.serialization.dsl.serialization import com.mineinabyss.geary.serialization.dsl.withCommonComponentNames import com.mineinabyss.geary.serialization.formats.YamlFormat @@ -11,7 +10,6 @@ import com.mineinabyss.geary.serialization.serializableComponents import com.mineinabyss.geary.serialization.serializers.GearyEntitySerializer import com.mineinabyss.geary.systems.builders.observeWithData import com.mineinabyss.idofront.di.DI -import io.kotest.assertions.print.Print import io.kotest.matchers.shouldBe import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -32,7 +30,7 @@ class ConfigEntityObserversTests { fun createEngine() { DI.clear() geary(TestEngineModule) { - install(Prefabs) + install(GearyActions) serialization { withCommonComponentNames() @@ -53,9 +51,8 @@ class ConfigEntityObserversTests { // arrange val entityDef = """ geary:observe: - - event: geary:onSet - involving: [ geary:myComp ] - emit: + geary:onSet: + # TODO involving: [ geary:myComp ] - geary:print: string: "Hello World" """.trimIndent() diff --git a/addons/geary-prefabs/src/commonMain/kotlin/com/mineinabyss/geary/prefabs/Prefabs.kt b/addons/geary-prefabs/src/commonMain/kotlin/com/mineinabyss/geary/prefabs/Prefabs.kt index 11e01ca9..aa4310d0 100644 --- a/addons/geary-prefabs/src/commonMain/kotlin/com/mineinabyss/geary/prefabs/Prefabs.kt +++ b/addons/geary-prefabs/src/commonMain/kotlin/com/mineinabyss/geary/prefabs/Prefabs.kt @@ -33,7 +33,6 @@ interface Prefabs { createParseRelationWithDataListener() createTrackPrefabsByKeyListener() createCopyToInstancesSystem() - bindEntityObservers() reEmitEvent() } geary.pipeline.runOnOrAfter(GearyPhase.INIT_ENTITIES) {