From f0adda7821e01158e1413335287c02b74bf00b08 Mon Sep 17 00:00:00 2001 From: Esoteric Enderman Date: Fri, 1 Nov 2024 21:48:17 +0000 Subject: [PATCH] Add resource pack zip file test --- .../minecraft/plugins/library/TestPlugin.kt | 6 +++- .../library/pack/resource/ResourcePackTest.kt | 28 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 lib/src/test/kotlin/foundation/esoteric/minecraft/plugins/library/pack/resource/ResourcePackTest.kt diff --git a/lib/src/test/kotlin/foundation/esoteric/minecraft/plugins/library/TestPlugin.kt b/lib/src/test/kotlin/foundation/esoteric/minecraft/plugins/library/TestPlugin.kt index 09ddf82..4720231 100644 --- a/lib/src/test/kotlin/foundation/esoteric/minecraft/plugins/library/TestPlugin.kt +++ b/lib/src/test/kotlin/foundation/esoteric/minecraft/plugins/library/TestPlugin.kt @@ -4,15 +4,19 @@ import foundation.esoteric.minecraft.plugins.library.file.FileManagedPlugin import foundation.esoteric.minecraft.plugins.library.file.FileManager import foundation.esoteric.minecraft.plugins.library.item.CustomItemManager import foundation.esoteric.minecraft.plugins.library.item.CustomItemPlugin +import foundation.esoteric.minecraft.plugins.library.pack.resource.ResourcePackManager +import foundation.esoteric.minecraft.plugins.library.pack.resource.ResourcePackPlugin import org.bukkit.plugin.java.JavaPlugin -open class TestPlugin : JavaPlugin(), FileManagedPlugin, CustomItemPlugin { +open class TestPlugin : JavaPlugin(), FileManagedPlugin, CustomItemPlugin, ResourcePackPlugin { + override lateinit var resourcePackManager: ResourcePackManager override lateinit var customItemManager: CustomItemManager override lateinit var fileManager: FileManager override fun onEnable() { fileManager = FileManager(this) customItemManager = CustomItemManager(this) + resourcePackManager = ResourcePackManager(this) } } diff --git a/lib/src/test/kotlin/foundation/esoteric/minecraft/plugins/library/pack/resource/ResourcePackTest.kt b/lib/src/test/kotlin/foundation/esoteric/minecraft/plugins/library/pack/resource/ResourcePackTest.kt new file mode 100644 index 0000000..9eb96bd --- /dev/null +++ b/lib/src/test/kotlin/foundation/esoteric/minecraft/plugins/library/pack/resource/ResourcePackTest.kt @@ -0,0 +1,28 @@ +package foundation.esoteric.minecraft.plugins.library.pack.resource + +import be.seeseemelk.mockbukkit.MockBukkit +import foundation.esoteric.minecraft.plugins.library.TestPlugin +import java.io.File +import kotlin.test.AfterTest +import kotlin.test.BeforeTest +import kotlin.test.Test +import kotlin.test.assertTrue + +class ResourcePackTest { + + private var plugin: TestPlugin? = null + + @BeforeTest fun mockResourcePackPlugin() { + MockBukkit.mock() + plugin = MockBukkit.load(TestPlugin::class.java) + } + + @Test fun resourcePackSavingWorks() { + val resourcePackFolder = File(plugin!!.dataFolder, "TestPluginResourcePack.zip") + assertTrue(resourcePackFolder.exists()) + } + + @AfterTest fun unmockResourcePackPlugin() { + MockBukkit.unmock() + } +}