-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Inheriting an entity should not inherit its prefabs directly
fix: Loading from JAR resources not working tests: Add tests for issues above
- Loading branch information
Showing
13 changed files
with
122 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
...geary-prefabs/src/jvmTest/kotlin/com/mineinabyss/geary/prefabs/PrefabFromResourcesTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.mineinabyss.geary.prefabs | ||
|
||
import com.mineinabyss.geary.modules.TestEngineModule | ||
import com.mineinabyss.geary.modules.geary | ||
import com.mineinabyss.geary.prefabs.PrefabsDSLExtensions.fromFiles | ||
import com.mineinabyss.geary.prefabs.PrefabsDSLExtensions.fromJarResourceDirectory | ||
import com.mineinabyss.geary.prefabs.PrefabsDSLExtensions.fromJarResources | ||
import com.mineinabyss.geary.serialization.formats.YamlFormat | ||
import com.mineinabyss.geary.serialization.serialization | ||
import io.kotest.matchers.shouldBe | ||
import io.kotest.matchers.shouldNotBe | ||
import org.junit.jupiter.api.Test | ||
|
||
class PrefabFromResourcesTest { | ||
private fun world() = geary(TestEngineModule) { | ||
serialization { | ||
format("yml", ::YamlFormat) | ||
} | ||
} | ||
|
||
@Test | ||
fun `should load prefabs from resource file`() { | ||
val world = world().configure { | ||
namespace("test") { | ||
prefabs { | ||
fromJarResources(PrefabFromResourcesTest::class, "prefabs/prefabA.yml") | ||
} | ||
} | ||
}.start() | ||
|
||
with(world) { | ||
entityOfOrNull(PrefabKey.of("test:prefabA")) shouldNotBe null | ||
entityOfOrNull(PrefabKey.of("test:prefabB")) shouldBe null | ||
} | ||
} | ||
|
||
@Test | ||
fun `should load prefabs from resources directory`() { | ||
val world = world().configure { | ||
namespace("test") { | ||
prefabs { | ||
fromJarResourceDirectory(PrefabFromResourcesTest::class, "prefabs") | ||
} | ||
} | ||
}.start() | ||
with(world) { | ||
entityOfOrNull(PrefabKey.of("test:prefabA")) shouldNotBe null | ||
entityOfOrNull(PrefabKey.of("test:prefabB")) shouldNotBe null | ||
} | ||
} | ||
|
||
@Test | ||
fun `should load prefabs from path source`() { | ||
val world = world().configure { | ||
namespace("test") { | ||
prefabs { | ||
fromFiles( | ||
PrefabsDSLExtensions.getResource( | ||
PrefabFromResourcesTest::class.java.classLoader, | ||
"prefabs/prefabA.yml" | ||
)!! | ||
) | ||
} | ||
} | ||
}.start() | ||
with(world) { | ||
entityOfOrNull(PrefabKey.of("test:prefabA")) shouldNotBe null | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters